Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/client/api-client/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type { QuerySerializerOptions } from "../core/bodySerializer.gen";
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer } from "../core/bodySerializer.gen";
export { buildClientParams } from "../core/params.gen";
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen";
export type { ServerSentEventsResult } from "../core/serverSentEvents.gen";
export type { ClientMeta } from "../core/types.gen";
export { createClient } from "./client.gen";
export type {
Client,
Expand Down
4 changes: 2 additions & 2 deletions app/client/api-client/client/utils.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'
export const createQuerySerializer = <T = unknown>({
parameters = {},
...args
}: QuerySerializerOptions = {}) => {
const querySerializer = (queryParams: T) => {
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
const querySerializer = (queryParams: T): string => {
const search: string[] = [];
if (queryParams && typeof queryParams === 'object') {
for (const name in queryParams) {
Expand Down
7 changes: 7 additions & 0 deletions app/client/api-client/core/auth.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export interface Auth {
* @default 'header'
*/
in?: 'header' | 'query' | 'cookie';
/**
* A unique identifier for the security scheme.
*
* Defined only when there are multiple security schemes whose `Auth`
* shape would otherwise be identical.
*/
key?: string;
/**
* Header or query parameter name.
*
Expand Down
18 changes: 10 additions & 8 deletions app/client/api-client/core/params.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type KeyMap = Map<
}
>;

const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
if (!map) {
map = new Map();
}
Expand All @@ -86,7 +86,7 @@ const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
}

return map;
};
}

interface Params {
body: unknown;
Expand All @@ -95,16 +95,18 @@ interface Params {
query: Record<string, unknown>;
}

const stripEmptySlots = (params: Params) => {
type ParamsSlotMap = Record<Slot, unknown>;

function stripEmptySlots(params: ParamsSlotMap): void {
for (const [slot, value] of Object.entries(params)) {
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
delete params[slot as Slot];
}
}
};
}

export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => {
const params: Params = {
export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {
const params: ParamsSlotMap = {
body: Object.create(null),
headers: Object.create(null),
path: Object.create(null),
Expand Down Expand Up @@ -166,5 +168,5 @@ export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsCo

stripEmptySlots(params);

return params;
};
return params as Params;
}
12 changes: 6 additions & 6 deletions app/client/api-client/core/pathSerializer.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface SerializePrimitiveParam extends SerializePrimitiveOptions {
value: string;
}

export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
export const separatorArrayExplode = (style: ArraySeparatorStyle): '.' | ';' | ',' | '&' => {
switch (style) {
case 'label':
return '.';
Expand All @@ -39,7 +39,7 @@ export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
}
};

export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
export const separatorArrayNoExplode = (style: ArraySeparatorStyle): ',' | '|' | '%20' => {
switch (style) {
case 'form':
return ',';
Expand All @@ -52,7 +52,7 @@ export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
}
};

export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
export const separatorObjectExplode = (style: ObjectSeparatorStyle): '.' | ';' | ',' | '&' => {
switch (style) {
case 'label':
return '.';
Expand All @@ -73,7 +73,7 @@ export const serializeArrayParam = ({
value,
}: SerializeOptions<ArraySeparatorStyle> & {
value: unknown[];
}) => {
}): string => {
if (!explode) {
const joinedValues = (
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
Expand Down Expand Up @@ -111,7 +111,7 @@ export const serializePrimitiveParam = ({
allowReserved,
name,
value,
}: SerializePrimitiveParam) => {
}: SerializePrimitiveParam): string => {
if (value === undefined || value === null) {
return '';
}
Expand All @@ -135,7 +135,7 @@ export const serializeObjectParam = ({
}: SerializeOptions<ObjectSeparatorStyle> & {
value: Record<string, unknown> | Date;
valueOnly?: boolean;
}) => {
}): string => {
if (value instanceof Date) {
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
}
Expand Down
2 changes: 1 addition & 1 deletion app/client/api-client/core/queryKeySerializer.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type JsonValue =
/**
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
*/
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
export const queryKeyJsonReplacer = (_key: string, value: unknown): unknown | undefined => {
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
return undefined;
}
Expand Down
6 changes: 6 additions & 0 deletions app/client/api-client/core/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export interface Config {
responseValidator?: (data: unknown) => Promise<unknown>;
}

/**
* Arbitrary metadata passed through the `meta` request option.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ClientMeta {}

type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
? true
: [T] extends [never | undefined]
Expand Down
8 changes: 4 additions & 4 deletions app/client/api-client/core/utils.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export interface PathSerializer {
url: string;
}

export const PATH_PARAM_RE = /\{[^{}]+\}/g;
export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g;

export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer): string => {
let url = _url;
const matches = _url.match(PATH_PARAM_RE);
if (matches) {
Expand Down Expand Up @@ -95,7 +95,7 @@ export const getUrl = ({
query?: Record<string, unknown>;
querySerializer: QuerySerializer;
url: string;
}) => {
}): string => {
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
let url = (baseUrl ?? '') + pathUrl;
if (path) {
Expand All @@ -115,7 +115,7 @@ export function getValidRequestBody(options: {
body?: unknown;
bodySerializer?: BodySerializer | null;
serializedBody?: unknown;
}) {
}): unknown {
const hasBody = options.body !== undefined;
const isSerializedBody = hasBody && options.bodySerializer;

Expand Down
Loading