@orpc/openapi-client
Version:
<div align="center"> <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> </div>
80 lines (73 loc) • 3.74 kB
text/typescript
import { ClientContext, ClientOptions } from '@orpc/client';
import { StandardLinkCodec, StandardLinkOptions, StandardLink, StandardLinkClient } from '@orpc/client/standard';
import { AnyContractRouter } from '@orpc/contract';
import { Segment, Value } from '@orpc/shared';
import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
type StandardBracketNotationSerialized = [string, unknown][];
declare class StandardBracketNotationSerializer {
serialize(data: unknown, segments?: Segment[], result?: StandardBracketNotationSerialized): StandardBracketNotationSerialized;
deserialize(serialized: StandardBracketNotationSerialized): Record<string, unknown> | unknown[];
stringifyPath(segments: readonly Segment[]): string;
parsePath(path: string): string[];
}
type StandardOpenAPIJsonSerialized = [json: unknown, hasBlob: boolean];
interface StandardOpenAPICustomJsonSerializer {
condition(data: unknown): boolean;
serialize(data: any): unknown;
}
interface StandardOpenAPIJsonSerializerOptions {
customJsonSerializers?: readonly StandardOpenAPICustomJsonSerializer[];
}
declare class StandardOpenAPIJsonSerializer {
private readonly customSerializers;
constructor(options?: StandardOpenAPIJsonSerializerOptions);
serialize(data: unknown, hasBlobRef?: {
value: boolean;
}): StandardOpenAPIJsonSerialized;
}
interface StandardOpenAPISerializeOptions {
outputFormat?: 'plain' | 'URLSearchParams';
}
declare class StandardOpenAPISerializer {
#private;
private readonly jsonSerializer;
private readonly bracketNotation;
constructor(jsonSerializer: StandardOpenAPIJsonSerializer, bracketNotation: StandardBracketNotationSerializer);
serialize(data: unknown, options?: StandardOpenAPISerializeOptions): unknown;
deserialize(data: unknown): unknown;
}
interface StandardOpenapiLinkCodecOptions<T extends ClientContext> {
/**
* Base url for all requests.
*/
url: Value<string | URL, [
options: ClientOptions<T>,
path: readonly string[],
input: unknown
]>;
/**
* Inject headers to the request.
*/
headers?: Value<StandardHeaders, [
options: ClientOptions<T>,
path: readonly string[],
input: unknown
]>;
}
declare class StandardOpenapiLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
#private;
private readonly contract;
private readonly serializer;
private readonly baseUrl;
private readonly headers;
constructor(contract: AnyContractRouter, serializer: StandardOpenAPISerializer, options: StandardOpenapiLinkCodecOptions<T>);
encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
decode(response: StandardLazyResponse, _options: ClientOptions<T>, path: readonly string[]): Promise<unknown>;
}
interface StandardOpenAPILinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardOpenapiLinkCodecOptions<T>, StandardOpenAPIJsonSerializerOptions {
}
declare class StandardOpenAPILink<T extends ClientContext> extends StandardLink<T> {
constructor(contract: AnyContractRouter, linkClient: StandardLinkClient<T>, options: StandardOpenAPILinkOptions<T>);
}
export { StandardBracketNotationSerializer as a, StandardOpenAPIJsonSerializer as e, StandardOpenAPILink as g, StandardOpenapiLinkCodec as i, StandardOpenAPISerializer as k };
export type { StandardBracketNotationSerialized as S, StandardOpenAPIJsonSerialized as b, StandardOpenAPICustomJsonSerializer as c, StandardOpenAPIJsonSerializerOptions as d, StandardOpenAPILinkOptions as f, StandardOpenapiLinkCodecOptions as h, StandardOpenAPISerializeOptions as j };