Skip to content

Commit 0d2bb6d

Browse files
Bump @hey-api/openapi-ts from 0.97.3 to 0.99.0 (#31)
1 parent 9391f91 commit 0d2bb6d

13 files changed

Lines changed: 233 additions & 156 deletions

openapi/client.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

33
import {
4+
type Client,
45
type ClientOptions,
56
type Config,
67
createClient,
@@ -20,6 +21,6 @@ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
2021
override?: Config<ClientOptions & T>,
2122
) => Config<Required<ClientOptions> & T>;
2223

23-
export const client = createClient(
24+
export const client: Client = createClient(
2425
createConfig<ClientOptions2>({ baseUrl: "/api" }),
2526
);

openapi/client/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export {
99
} from "../core/bodySerializer.gen.js";
1010
export { buildClientParams } from "../core/params.gen.js";
1111
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen.js";
12+
export type { ServerSentEventsResult } from "../core/serverSentEvents.gen.js";
13+
export type { ClientMeta } from "../core/types.gen.js";
1214
export { createClient } from "./client.gen.js";
1315
export type {
1416
Client,

openapi/client/utils.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import type {
1919
export const createQuerySerializer = <T = unknown>({
2020
parameters = {},
2121
...args
22-
}: QuerySerializerOptions = {}) => {
23-
const querySerializer = (queryParams: T) => {
22+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
23+
const querySerializer = (queryParams: T): string => {
2424
const search: string[] = [];
2525
if (queryParams && typeof queryParams === "object") {
2626
for (const name in queryParams) {

openapi/core/auth.gen.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ export interface Auth {
99
* @default 'header'
1010
*/
1111
in?: "header" | "query" | "cookie";
12+
/**
13+
* A unique identifier for the security scheme.
14+
*
15+
* Defined only when there are multiple security schemes whose `Auth`
16+
* shape would otherwise be identical.
17+
*/
18+
key?: string;
1219
/**
1320
* Header or query parameter name.
1421
*

openapi/core/params.gen.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type KeyMap = Map<
6262
}
6363
>;
6464

65-
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
65+
function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
6666
if (!map) {
6767
map = new Map();
6868
}
@@ -85,17 +85,18 @@ const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
8585
}
8686

8787
return map;
88-
};
88+
}
8989

9090
interface Params {
91-
body: unknown;
91+
body?: unknown;
9292
headers: Record<string, unknown>;
9393
path: Record<string, unknown>;
9494
query: Record<string, unknown>;
9595
}
9696

97-
const stripEmptySlots = (params: Params) => {
97+
function stripEmptySlots(params: Params): void {
9898
for (const [slot, value] of Object.entries(params)) {
99+
if (slot === "body") continue;
99100
if (
100101
value &&
101102
typeof value === "object" &&
@@ -105,21 +106,29 @@ const stripEmptySlots = (params: Params) => {
105106
delete params[slot as Slot];
106107
}
107108
}
108-
};
109+
}
109110

110-
export const buildClientParams = (
111+
export function buildClientParams(
111112
args: ReadonlyArray<unknown>,
112113
fields: FieldsConfig,
113-
) => {
114+
): Params {
114115
const params: Params = {
115-
body: Object.create(null),
116116
headers: Object.create(null),
117117
path: Object.create(null),
118118
query: Object.create(null),
119119
};
120120

121121
const map = buildKeyMap(fields);
122122

123+
function writeSlot(slot: Slot, key: string, value: unknown): void {
124+
let record = params[slot] as Record<string, unknown> | undefined;
125+
if (record === undefined) {
126+
record = Object.create(null) as Record<string, unknown>;
127+
params[slot] = record;
128+
}
129+
record[key] = value;
130+
}
131+
123132
let config: FieldsConfig[number] | undefined;
124133

125134
for (const [index, arg] of args.entries()) {
@@ -136,7 +145,7 @@ export const buildClientParams = (
136145
const field = map.get(config.key)!;
137146
const name = field.map || config.key;
138147
if (field.in) {
139-
(params[field.in] as Record<string, unknown>)[name] = arg;
148+
writeSlot(field.in, name, arg);
140149
}
141150
} else {
142151
params.body = arg;
@@ -148,7 +157,7 @@ export const buildClientParams = (
148157
if (field) {
149158
if (field.in) {
150159
const name = field.map || key;
151-
(params[field.in] as Record<string, unknown>)[name] = value;
160+
writeSlot(field.in, name, value);
152161
} else {
153162
params[field.map] = value;
154163
}
@@ -159,13 +168,11 @@ export const buildClientParams = (
159168

160169
if (extra) {
161170
const [prefix, slot] = extra;
162-
(params[slot] as Record<string, unknown>)[
163-
key.slice(prefix.length)
164-
] = value;
171+
writeSlot(slot, key.slice(prefix.length), value);
165172
} else if ("allowExtra" in config && config.allowExtra) {
166173
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
167174
if (allowed) {
168-
(params[slot as Slot] as Record<string, unknown>)[key] = value;
175+
writeSlot(slot as Slot, key, value);
169176
break;
170177
}
171178
}
@@ -178,4 +185,4 @@ export const buildClientParams = (
178185
stripEmptySlots(params);
179186

180187
return params;
181-
};
188+
}

openapi/core/pathSerializer.gen.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ interface SerializePrimitiveParam extends SerializePrimitiveOptions {
2626
value: string;
2727
}
2828

29-
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
29+
export const separatorArrayExplode = (
30+
style: ArraySeparatorStyle,
31+
): "." | ";" | "," | "&" => {
3032
switch (style) {
3133
case "label":
3234
return ".";
@@ -39,7 +41,9 @@ export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
3941
}
4042
};
4143

42-
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
44+
export const separatorArrayNoExplode = (
45+
style: ArraySeparatorStyle,
46+
): "," | "|" | "%20" => {
4347
switch (style) {
4448
case "form":
4549
return ",";
@@ -52,7 +56,9 @@ export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
5256
}
5357
};
5458

55-
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
59+
export const separatorObjectExplode = (
60+
style: ObjectSeparatorStyle,
61+
): "." | ";" | "," | "&" => {
5662
switch (style) {
5763
case "label":
5864
return ".";
@@ -73,7 +79,7 @@ export const serializeArrayParam = ({
7379
value,
7480
}: SerializeOptions<ArraySeparatorStyle> & {
7581
value: unknown[];
76-
}) => {
82+
}): string => {
7783
if (!explode) {
7884
const joinedValues = (
7985
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
@@ -113,7 +119,7 @@ export const serializePrimitiveParam = ({
113119
allowReserved,
114120
name,
115121
value,
116-
}: SerializePrimitiveParam) => {
122+
}: SerializePrimitiveParam): string => {
117123
if (value === undefined || value === null) {
118124
return "";
119125
}
@@ -137,7 +143,7 @@ export const serializeObjectParam = ({
137143
}: SerializeOptions<ObjectSeparatorStyle> & {
138144
value: Record<string, unknown> | Date;
139145
valueOnly?: boolean;
140-
}) => {
146+
}): string => {
141147
if (value instanceof Date) {
142148
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
143149
}

openapi/core/queryKeySerializer.gen.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export type JsonValue =
1414
/**
1515
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
1616
*/
17-
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
17+
export const queryKeyJsonReplacer = (
18+
_key: string,
19+
value: unknown,
20+
): unknown | undefined => {
1821
if (
1922
value === undefined ||
2023
typeof value === "function" ||

openapi/core/types.gen.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ export interface Config {
103103
responseValidator?: (data: unknown) => Promise<unknown>;
104104
}
105105

106+
/**
107+
* Arbitrary metadata passed through the `meta` request option.
108+
*/
109+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
110+
export interface ClientMeta {}
111+
106112
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
107113
? true
108114
: [T] extends [never | undefined]

openapi/core/utils.gen.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ export interface PathSerializer {
1313
url: string;
1414
}
1515

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

18-
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
18+
export const defaultPathSerializer = ({
19+
path,
20+
url: _url,
21+
}: PathSerializer): string => {
1922
let url = _url;
2023
const matches = _url.match(PATH_PARAM_RE);
2124
if (matches) {
@@ -97,7 +100,7 @@ export const getUrl = ({
97100
query?: Record<string, unknown>;
98101
querySerializer: QuerySerializer;
99102
url: string;
100-
}) => {
103+
}): string => {
101104
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
102105
let url = (baseUrl ?? "") + pathUrl;
103106
if (path) {
@@ -117,7 +120,7 @@ export function getValidRequestBody(options: {
117120
body?: unknown;
118121
bodySerializer?: BodySerializer | null;
119122
serializedBody?: unknown;
120-
}) {
123+
}): unknown {
121124
const hasBody = options.body !== undefined;
122125
const isSerializedBody = hasBody && options.bodySerializer;
123126

0 commit comments

Comments
 (0)