@hey-api/openapi-ts 0.97.3 → 0.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/angular/index.ts +1 -0
- package/dist/clients/angular/utils.ts +3 -3
- package/dist/clients/axios/index.ts +1 -0
- package/dist/clients/axios/utils.ts +2 -2
- package/dist/clients/core/auth.ts +7 -0
- package/dist/clients/core/params.ts +10 -8
- package/dist/clients/core/pathSerializer.ts +6 -6
- package/dist/clients/core/queryKeySerializer.ts +1 -1
- package/dist/clients/core/utils.ts +4 -4
- package/dist/clients/fetch/index.ts +1 -0
- package/dist/clients/fetch/utils.ts +2 -2
- package/dist/clients/ky/index.ts +1 -0
- package/dist/clients/ky/utils.ts +2 -2
- package/dist/clients/next/index.ts +1 -0
- package/dist/clients/next/utils.ts +3 -3
- package/dist/clients/nuxt/index.ts +1 -0
- package/dist/clients/nuxt/utils.ts +3 -3
- package/dist/clients/ofetch/index.ts +1 -0
- package/dist/clients/ofetch/utils.ts +2 -2
- package/dist/index.d.mts +178 -121
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{init-D3VuY80Z.mjs → init-BENFi6V7.mjs} +2086 -2461
- package/dist/init-BENFi6V7.mjs.map +1 -0
- package/dist/internal.d.mts +1 -1
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/dist/run.mjs.map +1 -1
- package/dist/{src-BeNy9O9X.mjs → src-BXIUXBF6.mjs} +5 -5
- package/dist/src-BXIUXBF6.mjs.map +1 -0
- package/dist/{types-KzipN7UT.d.mts → types-DH7EVLYi.d.mts} +2 -10
- package/dist/types-DH7EVLYi.d.mts.map +1 -0
- package/package.json +7 -7
- package/dist/init-D3VuY80Z.mjs.map +0 -1
- package/dist/src-BeNy9O9X.mjs.map +0 -1
- package/dist/types-KzipN7UT.d.mts.map +0 -1
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
|
@@ -93,8 +93,8 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
93
93
|
export const createQuerySerializer = <T = unknown>({
|
|
94
94
|
parameters = {},
|
|
95
95
|
...args
|
|
96
|
-
}: QuerySerializerOptions = {}) => {
|
|
97
|
-
const querySerializer = (queryParams: T) => {
|
|
96
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
97
|
+
const querySerializer = (queryParams: T): string => {
|
|
98
98
|
const search: string[] = [];
|
|
99
99
|
if (queryParams && typeof queryParams === 'object') {
|
|
100
100
|
for (const name in queryParams) {
|
|
@@ -240,7 +240,7 @@ export const getUrl = ({
|
|
|
240
240
|
query?: Record<string, unknown>;
|
|
241
241
|
querySerializer: QuerySerializer;
|
|
242
242
|
url: string;
|
|
243
|
-
}) => {
|
|
243
|
+
}): string => {
|
|
244
244
|
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
245
245
|
let url = (baseUrl ?? '') + pathUrl;
|
|
246
246
|
if (path) {
|
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
|
@@ -11,8 +11,8 @@ import type { Client, ClientOptions, Config, RequestOptions } from './types';
|
|
|
11
11
|
export const createQuerySerializer = <T = unknown>({
|
|
12
12
|
parameters = {},
|
|
13
13
|
...args
|
|
14
|
-
}: QuerySerializerOptions = {}) => {
|
|
15
|
-
const querySerializer = (queryParams: T) => {
|
|
14
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
15
|
+
const querySerializer = (queryParams: T): string => {
|
|
16
16
|
const search: string[] = [];
|
|
17
17
|
if (queryParams && typeof queryParams === 'object') {
|
|
18
18
|
for (const name in queryParams) {
|
|
@@ -7,6 +7,13 @@ export interface Auth {
|
|
|
7
7
|
* @default 'header'
|
|
8
8
|
*/
|
|
9
9
|
in?: 'header' | 'query' | 'cookie';
|
|
10
|
+
/**
|
|
11
|
+
* A unique identifier for the security scheme.
|
|
12
|
+
*
|
|
13
|
+
* Defined only when there are multiple security schemes whose `Auth`
|
|
14
|
+
* shape would otherwise be identical.
|
|
15
|
+
*/
|
|
16
|
+
key?: string;
|
|
10
17
|
/**
|
|
11
18
|
* Header or query parameter name.
|
|
12
19
|
*
|
|
@@ -60,7 +60,7 @@ type KeyMap = Map<
|
|
|
60
60
|
}
|
|
61
61
|
>;
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
|
|
64
64
|
if (!map) {
|
|
65
65
|
map = new Map();
|
|
66
66
|
}
|
|
@@ -83,7 +83,7 @@ const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return map;
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
87
|
|
|
88
88
|
interface Params {
|
|
89
89
|
body: unknown;
|
|
@@ -92,16 +92,18 @@ interface Params {
|
|
|
92
92
|
query: Record<string, unknown>;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
type ParamsSlotMap = Record<Slot, unknown>;
|
|
96
|
+
|
|
97
|
+
function stripEmptySlots(params: ParamsSlotMap): void {
|
|
96
98
|
for (const [slot, value] of Object.entries(params)) {
|
|
97
99
|
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
|
|
98
100
|
delete params[slot as Slot];
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
|
-
}
|
|
103
|
+
}
|
|
102
104
|
|
|
103
|
-
export
|
|
104
|
-
const params:
|
|
105
|
+
export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {
|
|
106
|
+
const params: ParamsSlotMap = {
|
|
105
107
|
body: Object.create(null),
|
|
106
108
|
headers: Object.create(null),
|
|
107
109
|
path: Object.create(null),
|
|
@@ -163,5 +165,5 @@ export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsCo
|
|
|
163
165
|
|
|
164
166
|
stripEmptySlots(params);
|
|
165
167
|
|
|
166
|
-
return params;
|
|
167
|
-
}
|
|
168
|
+
return params as Params;
|
|
169
|
+
}
|
|
@@ -23,7 +23,7 @@ interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
|
23
23
|
value: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
26
|
+
export const separatorArrayExplode = (style: ArraySeparatorStyle): '.' | ';' | ',' | '&' => {
|
|
27
27
|
switch (style) {
|
|
28
28
|
case 'label':
|
|
29
29
|
return '.';
|
|
@@ -36,7 +36,7 @@ export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
39
|
+
export const separatorArrayNoExplode = (style: ArraySeparatorStyle): ',' | '|' | '%20' => {
|
|
40
40
|
switch (style) {
|
|
41
41
|
case 'form':
|
|
42
42
|
return ',';
|
|
@@ -49,7 +49,7 @@ export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
|
52
|
+
export const separatorObjectExplode = (style: ObjectSeparatorStyle): '.' | ';' | ',' | '&' => {
|
|
53
53
|
switch (style) {
|
|
54
54
|
case 'label':
|
|
55
55
|
return '.';
|
|
@@ -70,7 +70,7 @@ export const serializeArrayParam = ({
|
|
|
70
70
|
value,
|
|
71
71
|
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
72
72
|
value: unknown[];
|
|
73
|
-
}) => {
|
|
73
|
+
}): string => {
|
|
74
74
|
if (!explode) {
|
|
75
75
|
const joinedValues = (
|
|
76
76
|
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
|
@@ -108,7 +108,7 @@ export const serializePrimitiveParam = ({
|
|
|
108
108
|
allowReserved,
|
|
109
109
|
name,
|
|
110
110
|
value,
|
|
111
|
-
}: SerializePrimitiveParam) => {
|
|
111
|
+
}: SerializePrimitiveParam): string => {
|
|
112
112
|
if (value === undefined || value === null) {
|
|
113
113
|
return '';
|
|
114
114
|
}
|
|
@@ -132,7 +132,7 @@ export const serializeObjectParam = ({
|
|
|
132
132
|
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
133
133
|
value: Record<string, unknown> | Date;
|
|
134
134
|
valueOnly?: boolean;
|
|
135
|
-
}) => {
|
|
135
|
+
}): string => {
|
|
136
136
|
if (value instanceof Date) {
|
|
137
137
|
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
138
138
|
}
|
|
@@ -12,7 +12,7 @@ export type JsonValue =
|
|
|
12
12
|
/**
|
|
13
13
|
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
14
14
|
*/
|
|
15
|
-
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
|
15
|
+
export const queryKeyJsonReplacer = (_key: string, value: unknown): unknown | undefined => {
|
|
16
16
|
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
|
17
17
|
return undefined;
|
|
18
18
|
}
|
|
@@ -11,9 +11,9 @@ export interface PathSerializer {
|
|
|
11
11
|
url: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
14
|
+
export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g;
|
|
15
15
|
|
|
16
|
-
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
16
|
+
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer): string => {
|
|
17
17
|
let url = _url;
|
|
18
18
|
const matches = _url.match(PATH_PARAM_RE);
|
|
19
19
|
if (matches) {
|
|
@@ -92,7 +92,7 @@ export const getUrl = ({
|
|
|
92
92
|
query?: Record<string, unknown>;
|
|
93
93
|
querySerializer: QuerySerializer;
|
|
94
94
|
url: string;
|
|
95
|
-
}) => {
|
|
95
|
+
}): string => {
|
|
96
96
|
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
97
97
|
let url = (baseUrl ?? '') + pathUrl;
|
|
98
98
|
if (path) {
|
|
@@ -112,7 +112,7 @@ export function getValidRequestBody(options: {
|
|
|
112
112
|
body?: unknown;
|
|
113
113
|
bodySerializer?: BodySerializer | null;
|
|
114
114
|
serializedBody?: unknown;
|
|
115
|
-
}) {
|
|
115
|
+
}): unknown {
|
|
116
116
|
const hasBody = options.body !== undefined;
|
|
117
117
|
const isSerializedBody = hasBody && options.bodySerializer;
|
|
118
118
|
|
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
|
@@ -12,8 +12,8 @@ import type { Client, ClientOptions, Config, RequestOptions } from './types';
|
|
|
12
12
|
export const createQuerySerializer = <T = unknown>({
|
|
13
13
|
parameters = {},
|
|
14
14
|
...args
|
|
15
|
-
}: QuerySerializerOptions = {}) => {
|
|
16
|
-
const querySerializer = (queryParams: T) => {
|
|
15
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
16
|
+
const querySerializer = (queryParams: T): string => {
|
|
17
17
|
const search: string[] = [];
|
|
18
18
|
if (queryParams && typeof queryParams === 'object') {
|
|
19
19
|
for (const name in queryParams) {
|
package/dist/clients/ky/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
package/dist/clients/ky/utils.ts
CHANGED
|
@@ -12,8 +12,8 @@ import type { Client, ClientOptions, Config, RequestOptions } from './types';
|
|
|
12
12
|
export const createQuerySerializer = <T = unknown>({
|
|
13
13
|
parameters = {},
|
|
14
14
|
...args
|
|
15
|
-
}: QuerySerializerOptions = {}) => {
|
|
16
|
-
const querySerializer = (queryParams: T) => {
|
|
15
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
16
|
+
const querySerializer = (queryParams: T): string => {
|
|
17
17
|
const search: string[] = [];
|
|
18
18
|
if (queryParams && typeof queryParams === 'object') {
|
|
19
19
|
for (const name in queryParams) {
|
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
|
@@ -92,8 +92,8 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
92
92
|
export const createQuerySerializer = <T = unknown>({
|
|
93
93
|
parameters = {},
|
|
94
94
|
...args
|
|
95
|
-
}: QuerySerializerOptions = {}) => {
|
|
96
|
-
const querySerializer = (queryParams: T) => {
|
|
95
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
96
|
+
const querySerializer = (queryParams: T): string => {
|
|
97
97
|
const search: string[] = [];
|
|
98
98
|
if (queryParams && typeof queryParams === 'object') {
|
|
99
99
|
for (const name in queryParams) {
|
|
@@ -257,7 +257,7 @@ export const getUrl = ({
|
|
|
257
257
|
query?: Record<string, unknown>;
|
|
258
258
|
querySerializer: QuerySerializer;
|
|
259
259
|
url: string;
|
|
260
|
-
}) => {
|
|
260
|
+
}): string => {
|
|
261
261
|
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
262
262
|
let url = (baseUrl ?? '') + pathUrl;
|
|
263
263
|
if (path) {
|
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
|
@@ -95,8 +95,8 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
95
95
|
export const createQuerySerializer = <T = unknown>({
|
|
96
96
|
parameters = {},
|
|
97
97
|
...args
|
|
98
|
-
}: QuerySerializerOptions = {}) => {
|
|
99
|
-
const querySerializer = (queryParams: T) => {
|
|
98
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
99
|
+
const querySerializer = (queryParams: T): string => {
|
|
100
100
|
const search: string[] = [];
|
|
101
101
|
const qParams = toValue(queryParams);
|
|
102
102
|
if (qParams && typeof qParams === 'object') {
|
|
@@ -225,7 +225,7 @@ export const getUrl = ({
|
|
|
225
225
|
}: Pick<BuildUrlOptions, 'path' | 'query' | 'url'> & {
|
|
226
226
|
baseUrl?: string;
|
|
227
227
|
querySerializer: QuerySerializer;
|
|
228
|
-
}) => {
|
|
228
|
+
}): string => {
|
|
229
229
|
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
230
230
|
let url = (baseUrl ?? '') + pathUrl;
|
|
231
231
|
if (path) {
|
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
9
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
10
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents';
|
|
10
11
|
export { createClient } from './client';
|
|
11
12
|
export type {
|
|
12
13
|
Client,
|
|
@@ -21,8 +21,8 @@ import type {
|
|
|
21
21
|
export const createQuerySerializer = <T = unknown>({
|
|
22
22
|
parameters = {},
|
|
23
23
|
...args
|
|
24
|
-
}: QuerySerializerOptions = {}) => {
|
|
25
|
-
const querySerializer = (queryParams: T) => {
|
|
24
|
+
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
|
25
|
+
const querySerializer = (queryParams: T): string => {
|
|
26
26
|
const search: string[] = [];
|
|
27
27
|
if (queryParams && typeof queryParams === 'object') {
|
|
28
28
|
for (const name in queryParams) {
|