import { HttpHeaders, HttpClient, HttpResourceOptions, HttpResourceRef } from '@angular/common/http'; import { Observable } from 'rxjs'; import { MediaType, Readable, SuccessResponse, ResponseObjectMap, RequiredKeysOf, Writable, OperationRequestBodyContent, IsOperationRequestBodyOptional, HttpMethod, PathsWithMethod, FilterKeys } from 'openapi-typescript-helpers'; import { Injector } from '@angular/core'; type HttpClientResponse, Media extends MediaType> = Readable, Media>>; type QuerySerializer = (query: T extends { parameters: any; } ? NonNullable : Record) => string; /** @see https://swagger.io/docs/specification/serialization/#query */ interface QuerySerializerOptions { /** Set serialization for arrays. @see https://swagger.io/docs/specification/serialization/#query */ array?: { /** default: "form" */ style: 'form' | 'spaceDelimited' | 'pipeDelimited'; /** default: true */ explode: boolean; }; /** Set serialization for objects. @see https://swagger.io/docs/specification/serialization/#query */ object?: { /** default: "deepObject" */ style: 'form' | 'deepObject'; /** default: true */ explode: boolean; }; /** * The `allowReserved` keyword specifies whether the reserved characters * `:/?#[]@!$&'()*+,;=` in parameter values are allowed to be sent as they * are, or should be percent-encoded. By default, allowReserved is `false`, * and reserved characters are percent-encoded. * @see https://swagger.io/docs/specification/serialization/#query */ allowReserved?: boolean; } interface DefaultParamsOption { params?: { query?: Record; }; } type ParamsOption = T extends { parameters: any; } ? RequiredKeysOf extends never ? { params?: T['parameters']; } : { params: T['parameters']; } : DefaultParamsOption; type MultipartFormData = T extends { requestBody?: infer RequestBody; } ? NonNullable extends { content: infer Content; } ? 'multipart/form-data' extends keyof Content ? FormData : never : never : never; type SerializedStringBody = Extract>, string> extends never ? never : string; type RequestBody = OperationRequestBodyContent | MultipartFormData | SerializedStringBody; type RequestBodyOption = Writable> extends never ? { body?: never; } : IsOperationRequestBodyOptional extends true ? { body?: Writable>; } : { body: Writable>; }; type RequestOptions = ParamsOption & RequestBodyOption & { baseUrl?: string; headers?: HttpHeaders; querySerializer?: QuerySerializer | QuerySerializerOptions; }; /** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */ type MaybeOptionalInit = RequiredKeysOf>> extends never ? RequestOptions> | undefined : RequestOptions>; type InitParam$1 = RequiredKeysOf extends never ? [(Init & Record)?] : [Init & Record]; type ClientMethod>, Method extends HttpMethod, Media extends MediaType> = , Init extends MaybeOptionalInit>(url: Path, ...init: InitParam$1) => Observable>; type ClientRequestMethod>, Media extends MediaType> = , Init extends MaybeOptionalInit>(method: Method, url: Path, ...init: InitParam$1) => Observable>; interface OpenAPIHttpClientOptions { baseUrl: string; querySerializer?: QuerySerializer | QuerySerializerOptions; } declare function createOpenAPIHttpClient>(httpClient: HttpClient, options: OpenAPIHttpClientOptions): OpenAPIHttpClient; declare class OpenAPIHttpClient, Media extends MediaType = MediaType> { private http; private readonly baseUrl; private readonly querySerializer?; constructor(http: HttpClient, { baseUrl, querySerializer }: OpenAPIHttpClientOptions); core, Init extends MaybeOptionalInit, Method extends HttpMethod>(method: Method, path: Path, options: InitParam$1): Observable>; request: ClientRequestMethod; get: ClientMethod; put: ClientMethod; post: ClientMethod; delete: ClientMethod; options: ClientMethod; head: ClientMethod; patch: ClientMethod; } /** * Strongly-typed OpenAPI Resource builder on top of Angular's httpResource. * * - Preserves dfx-openapi type inference (paths, params, body, and typed responses) * - Reactive by design: pass a function that reads signals; when those signals change, * the resource re-fetches. * - Supports per-resource httpResource options via `http` field. */ interface OpenAPIResourceOptions { baseUrl: string; querySerializer?: QuerySerializer | QuerySerializerOptions; } /** * Allow per-resource httpResource options via `http` property, while preserving * OpenAPI request options shape. */ type WithHttpOptions = Init & { http?: HttpResourceOptions; }; /** * Make the single `init` argument optionally present based on whether params/body * are required for the specific operation. The init can be either a plain object * or a getter function (() => object | undefined) for reactivity. */ type InitGetterOrValue = Init | (() => Init | undefined); type InitParam = RequiredKeysOf extends never ? [InitGetterOrValue?] : [InitGetterOrValue]; /** * Factory: create a typed OpenAPI Resource builder. * Use this once per API (e.g. per `Paths`) and reuse it throughout your app. */ declare function createOpenAPIResource, Media extends MediaType = MediaType>(options: OpenAPIResourceOptions, injector?: Injector): OpenAPIResource; /** * OpenAPIResource returns HttpResourceRefs that refetch reactively when any * signals used inside your init getter (path/params/body) change. */ declare class OpenAPIResource, Media extends MediaType = MediaType> { private injector; private readonly baseUrl; private readonly querySerializer?; constructor({ baseUrl, querySerializer }: OpenAPIResourceOptions, injector: Injector); /** * Core resource method. Prefer using the per-method helpers below. * * Example: * const users = api.request('get', () => '/users', () => ({ * params: { query: { page: pageSignal() } }, * http: { defaultValue: [] } * })); */ core>(method: Method, path: () => Path | undefined, ...initParam: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; request>(method: Method, path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; get>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; put>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; post>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; delete>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; options>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; head>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; patch>(path: () => Path | undefined, ...init: InitParam>, HttpClientResponse, unknown>>): HttpResourceRef | undefined>; } export { OpenAPIHttpClient, OpenAPIResource, createOpenAPIHttpClient, createOpenAPIResource }; export type { ClientRequestMethod, OpenAPIHttpClientOptions, OpenAPIResourceOptions };