import type { FetchOptions, HeadersOptions } from 'openapi-fetch';
import type { paths } from '../generated/api.js';
import type { RetryOptions } from './retry.js';
export type OperationFor<Path extends keyof paths & string, Method extends keyof paths[Path] & string> = paths[Path][Method];
type OptionalizeWorkspacePath<PathParams> = PathParams extends {
    workspace_id: infer WorkspaceId;
} ? Omit<PathParams, 'workspace_id'> & {
    workspace_id?: WorkspaceId;
} : PathParams;
type EmptyShape = Record<never, never>;
type RewriteParams<Options> = Options extends {
    params: infer Params;
} ? RewriteParamShape<Params> extends infer RewrittenParams ? RewrittenParams extends object ? RequiredKeysOf<RewrittenParams> extends never ? Omit<Options, 'params'> & {
    params?: RewrittenParams;
} : Omit<Options, 'params'> & {
    params: RewrittenParams;
} : Omit<Options, 'params'> & {
    params: RewrittenParams;
} : Options : Options extends {
    params?: infer Params;
} ? Omit<Options, 'params'> & {
    params?: RewriteParamShape<Params>;
} : Options;
type RewriteParamShape<Params> = Params extends object ? Omit<Params, 'path'> & RewritePathParam<Params> : Params;
type RewritePathParam<Params> = Params extends {
    path: infer PathParams;
} ? OptionalizeWorkspacePath<PathParams> extends infer RewrittenPath ? RewrittenPath extends object ? RequiredKeysOf<RewrittenPath> extends never ? {
    path?: RewrittenPath;
} : {
    path: RewrittenPath;
} : {
    path: RewrittenPath;
} : EmptyShape : EmptyShape;
type RequiredKeysOf<T extends object> = Exclude<{
    [K in keyof T]-?: EmptyShape extends Pick<T, K> ? never : K;
}[keyof T], undefined>;
export type InitParam<Init extends object> = RequiredKeysOf<Init> extends never ? [init?: Init] : [init: Init];
export type AmigoRequestOptions<Operation = unknown> = Omit<RewriteParams<FetchOptions<Operation>>, 'timeout' | 'maxRetries' | 'retry'> & {
    timeout?: number;
    maxRetries?: number;
    retry?: RetryOptions;
};
export type ScopedRequestOptions = Omit<RequestInit, 'body' | 'headers' | 'method'> & {
    headers?: HeadersOptions;
    timeout?: number;
    maxRetries?: number;
    retry?: RetryOptions;
};
export interface RequestControlOptions {
    timeout?: number;
    maxRetries?: number;
    retry?: RetryOptions;
}
type MergeableRequestOptions = object & {
    headers?: HeadersOptions;
    signal?: AbortSignal | null;
    timeout?: number;
    maxRetries?: number;
    retry?: RetryOptions;
};
export declare function stripRequestControls<Options extends RequestControlOptions>(options: Options | undefined): Omit<Options, keyof RequestControlOptions> | undefined;
export declare function mergeRequestOptions<Options extends object>(base: ScopedRequestOptions | undefined, override: Options | undefined): (Options & MergeableRequestOptions) | undefined;
export declare function mergeScopedRequestOptions(base: ScopedRequestOptions | undefined, override: ScopedRequestOptions): ScopedRequestOptions;
export declare function mergeHeaders(base: HeadersOptions | undefined, override: HeadersOptions | undefined): Headers | undefined;
export {};
//# sourceMappingURL=request-options.d.ts.map