@hey-api/openapi-ts 0.84.4 → 0.85.1
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/bin/index.cjs +2 -1
- package/dist/chunk-SA4IKOSG.js +47 -0
- package/dist/chunk-SA4IKOSG.js.map +1 -0
- package/dist/clients/angular/index.ts +1 -0
- package/dist/clients/axios/index.ts +1 -0
- package/dist/clients/core/queryKeySerializer.ts +134 -0
- package/dist/clients/fetch/index.ts +1 -0
- package/dist/clients/next/index.ts +1 -0
- package/dist/clients/nuxt/index.ts +1 -0
- package/dist/clients/ofetch/index.ts +1 -0
- package/dist/index.cjs +87 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -12
- package/dist/index.d.ts +18 -12
- package/dist/index.js +182 -163
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +12 -12
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +26 -18
- package/dist/internal.d.ts +26 -18
- package/dist/internal.js +1 -1
- package/dist/{types.d-fB2fiwrL.d.cts → types.d-DIu3K5QP.d.cts} +253 -126
- package/dist/{types.d-fB2fiwrL.d.ts → types.d-DIu3K5QP.d.ts} +253 -126
- package/package.json +5 -5
- package/dist/chunk-6VWHNSOV.js +0 -54
- package/dist/chunk-6VWHNSOV.js.map +0 -1
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
urlSearchParamsBodySerializer,
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
9
10
|
export { createClient } from './client';
|
|
10
11
|
export type {
|
|
11
12
|
Client,
|
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
urlSearchParamsBodySerializer,
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
9
10
|
export { createClient } from './client';
|
|
10
11
|
export type {
|
|
11
12
|
Client,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
3
|
+
*/
|
|
4
|
+
export type JsonValue =
|
|
5
|
+
| null
|
|
6
|
+
| string
|
|
7
|
+
| number
|
|
8
|
+
| boolean
|
|
9
|
+
| JsonValue[]
|
|
10
|
+
| { [key: string]: JsonValue };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
14
|
+
*/
|
|
15
|
+
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
|
16
|
+
if (
|
|
17
|
+
value === undefined ||
|
|
18
|
+
typeof value === 'function' ||
|
|
19
|
+
typeof value === 'symbol'
|
|
20
|
+
) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === 'bigint') {
|
|
24
|
+
return value.toString();
|
|
25
|
+
}
|
|
26
|
+
if (value instanceof Date) {
|
|
27
|
+
return value.toISOString();
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Safely stringifies a value and parses it back into a JsonValue.
|
|
34
|
+
*/
|
|
35
|
+
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
|
36
|
+
try {
|
|
37
|
+
const json = JSON.stringify(input, queryKeyJsonReplacer);
|
|
38
|
+
if (json === undefined) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return JSON.parse(json) as JsonValue;
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Detects plain objects (including objects with a null prototype).
|
|
49
|
+
*/
|
|
50
|
+
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
|
51
|
+
if (value === null || typeof value !== 'object') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const prototype = Object.getPrototypeOf(value as object);
|
|
55
|
+
return prototype === Object.prototype || prototype === null;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
|
60
|
+
*/
|
|
61
|
+
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
|
62
|
+
const entries = Array.from(params.entries()).sort(([a], [b]) =>
|
|
63
|
+
a.localeCompare(b),
|
|
64
|
+
);
|
|
65
|
+
const result: Record<string, JsonValue> = {};
|
|
66
|
+
|
|
67
|
+
for (const [key, value] of entries) {
|
|
68
|
+
const existing = result[key];
|
|
69
|
+
if (existing === undefined) {
|
|
70
|
+
result[key] = value;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (Array.isArray(existing)) {
|
|
75
|
+
(existing as string[]).push(value);
|
|
76
|
+
} else {
|
|
77
|
+
result[key] = [existing, value];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
86
|
+
*/
|
|
87
|
+
export const serializeQueryKeyValue = (
|
|
88
|
+
value: unknown,
|
|
89
|
+
): JsonValue | undefined => {
|
|
90
|
+
if (value === null) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (
|
|
95
|
+
typeof value === 'string' ||
|
|
96
|
+
typeof value === 'number' ||
|
|
97
|
+
typeof value === 'boolean'
|
|
98
|
+
) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (
|
|
103
|
+
value === undefined ||
|
|
104
|
+
typeof value === 'function' ||
|
|
105
|
+
typeof value === 'symbol'
|
|
106
|
+
) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (typeof value === 'bigint') {
|
|
111
|
+
return value.toString();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (value instanceof Date) {
|
|
115
|
+
return value.toISOString();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (Array.isArray(value)) {
|
|
119
|
+
return stringifyToJsonValue(value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (
|
|
123
|
+
typeof URLSearchParams !== 'undefined' &&
|
|
124
|
+
value instanceof URLSearchParams
|
|
125
|
+
) {
|
|
126
|
+
return serializeSearchParams(value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (isPlainObject(value)) {
|
|
130
|
+
return stringifyToJsonValue(value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return undefined;
|
|
134
|
+
};
|
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
urlSearchParamsBodySerializer,
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
9
10
|
export { createClient } from './client';
|
|
10
11
|
export type {
|
|
11
12
|
Client,
|
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
urlSearchParamsBodySerializer,
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
9
10
|
export { createClient } from './client';
|
|
10
11
|
export type {
|
|
11
12
|
Client,
|
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
urlSearchParamsBodySerializer,
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
9
10
|
export { createClient } from './client';
|
|
10
11
|
export type {
|
|
11
12
|
Client,
|
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
urlSearchParamsBodySerializer,
|
|
7
7
|
} from '../core/bodySerializer';
|
|
8
8
|
export { buildClientParams } from '../core/params';
|
|
9
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer';
|
|
9
10
|
export { createClient } from './client';
|
|
10
11
|
export type {
|
|
11
12
|
Client,
|