waldur-js-client 8.0.9-dev.30 → 8.0.9-dev.32
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/client/{client.d.ts → client.gen.d.ts} +1 -1
- package/dist/client/client.gen.js +216 -0
- package/dist/client/index.d.ts +8 -7
- package/dist/client/index.js +6 -4
- package/dist/client/{types.d.ts → types.gen.d.ts} +22 -21
- package/dist/client/types.gen.js +2 -0
- package/dist/client/{utils.d.ts → utils.gen.d.ts} +16 -24
- package/dist/client/{utils.js → utils.gen.js} +65 -121
- package/dist/client.gen.d.ts +3 -3
- package/dist/core/{auth.js → auth.gen.js} +1 -0
- package/dist/core/bodySerializer.gen.d.ts +25 -0
- package/dist/core/{bodySerializer.js → bodySerializer.gen.js} +5 -1
- package/dist/core/{params.d.ts → params.gen.d.ts} +20 -0
- package/dist/core/{params.js → params.gen.js} +23 -10
- package/dist/core/{pathSerializer.js → pathSerializer.gen.js} +4 -11
- package/dist/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/core/queryKeySerializer.gen.js +92 -0
- package/dist/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/core/serverSentEvents.gen.js +132 -0
- package/dist/core/{types.d.ts → types.gen.d.ts} +20 -15
- package/dist/core/types.gen.js +2 -0
- package/dist/core/utils.gen.d.ts +19 -0
- package/dist/core/utils.gen.js +87 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/sdk.gen.d.ts +1061 -4
- package/dist/sdk.gen.js +28375 -55513
- package/dist/types.gen.d.ts +604 -422
- package/package.json +1 -1
- package/dist/client/client.js +0 -143
- package/dist/client/types.js +0 -1
- package/dist/core/bodySerializer.d.ts +0 -17
- package/dist/core/types.js +0 -1
- /package/dist/core/{auth.d.ts → auth.gen.d.ts} +0 -0
- /package/dist/core/{pathSerializer.d.ts → pathSerializer.gen.d.ts} +0 -0
|
@@ -1,59 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
8
|
-
if (matches) {
|
|
9
|
-
for (const match of matches) {
|
|
10
|
-
let explode = false;
|
|
11
|
-
let name = match.substring(1, match.length - 1);
|
|
12
|
-
let style = 'simple';
|
|
13
|
-
if (name.endsWith('*')) {
|
|
14
|
-
explode = true;
|
|
15
|
-
name = name.substring(0, name.length - 1);
|
|
16
|
-
}
|
|
17
|
-
if (name.startsWith('.')) {
|
|
18
|
-
name = name.substring(1);
|
|
19
|
-
style = 'label';
|
|
20
|
-
}
|
|
21
|
-
else if (name.startsWith(';')) {
|
|
22
|
-
name = name.substring(1);
|
|
23
|
-
style = 'matrix';
|
|
24
|
-
}
|
|
25
|
-
const value = path[name];
|
|
26
|
-
if (value === undefined || value === null) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(value)) {
|
|
30
|
-
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (typeof value === 'object') {
|
|
34
|
-
url = url.replace(match, serializeObjectParam({
|
|
35
|
-
explode,
|
|
36
|
-
name,
|
|
37
|
-
style,
|
|
38
|
-
value: value,
|
|
39
|
-
valueOnly: true,
|
|
40
|
-
}));
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (style === 'matrix') {
|
|
44
|
-
url = url.replace(match, `;${serializePrimitiveParam({
|
|
45
|
-
name,
|
|
46
|
-
value: value,
|
|
47
|
-
})}`);
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
|
|
51
|
-
url = url.replace(match, replaceValue);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return url;
|
|
55
|
-
};
|
|
56
|
-
export const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { getAuthToken } from '../core/auth.gen';
|
|
3
|
+
import { jsonBodySerializer } from '../core/bodySerializer.gen';
|
|
4
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from '../core/pathSerializer.gen';
|
|
5
|
+
import { getUrl } from '../core/utils.gen';
|
|
6
|
+
export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
57
7
|
const querySerializer = (queryParams) => {
|
|
58
8
|
const search = [];
|
|
59
9
|
if (queryParams && typeof queryParams === 'object') {
|
|
@@ -62,33 +12,34 @@ export const createQuerySerializer = ({ allowReserved, array, object, } = {}) =>
|
|
|
62
12
|
if (value === undefined || value === null) {
|
|
63
13
|
continue;
|
|
64
14
|
}
|
|
15
|
+
const options = parameters[name] || args;
|
|
65
16
|
if (Array.isArray(value)) {
|
|
66
17
|
const serializedArray = serializeArrayParam({
|
|
67
|
-
allowReserved,
|
|
18
|
+
allowReserved: options.allowReserved,
|
|
68
19
|
explode: true,
|
|
69
20
|
name,
|
|
70
21
|
style: 'form',
|
|
71
22
|
value,
|
|
72
|
-
...array,
|
|
23
|
+
...options.array,
|
|
73
24
|
});
|
|
74
25
|
if (serializedArray)
|
|
75
26
|
search.push(serializedArray);
|
|
76
27
|
}
|
|
77
28
|
else if (typeof value === 'object') {
|
|
78
29
|
const serializedObject = serializeObjectParam({
|
|
79
|
-
allowReserved,
|
|
30
|
+
allowReserved: options.allowReserved,
|
|
80
31
|
explode: true,
|
|
81
32
|
name,
|
|
82
33
|
style: 'deepObject',
|
|
83
34
|
value: value,
|
|
84
|
-
...object,
|
|
35
|
+
...options.object,
|
|
85
36
|
});
|
|
86
37
|
if (serializedObject)
|
|
87
38
|
search.push(serializedObject);
|
|
88
39
|
}
|
|
89
40
|
else {
|
|
90
41
|
const serializedPrimitive = serializePrimitiveParam({
|
|
91
|
-
allowReserved,
|
|
42
|
+
allowReserved: options.allowReserved,
|
|
92
43
|
name,
|
|
93
44
|
value: value,
|
|
94
45
|
});
|
|
@@ -114,8 +65,7 @@ export const getParseAs = (contentType) => {
|
|
|
114
65
|
if (!cleanContent) {
|
|
115
66
|
return;
|
|
116
67
|
}
|
|
117
|
-
if (cleanContent.startsWith('application/json') ||
|
|
118
|
-
cleanContent.endsWith('+json')) {
|
|
68
|
+
if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
|
|
119
69
|
return 'json';
|
|
120
70
|
}
|
|
121
71
|
if (cleanContent === 'multipart/form-data') {
|
|
@@ -129,8 +79,22 @@ export const getParseAs = (contentType) => {
|
|
|
129
79
|
}
|
|
130
80
|
return;
|
|
131
81
|
};
|
|
132
|
-
|
|
133
|
-
|
|
82
|
+
const checkForExistence = (options, name) => {
|
|
83
|
+
if (!name) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (options.headers.has(name) ||
|
|
87
|
+
options.query?.[name] ||
|
|
88
|
+
options.headers.get('Cookie')?.includes(`${name}=`)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
export async function setAuthParams(options) {
|
|
94
|
+
for (const auth of options.security ?? []) {
|
|
95
|
+
if (checkForExistence(options, auth.name)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
134
98
|
const token = await getAuthToken(auth, options.auth);
|
|
135
99
|
if (!token) {
|
|
136
100
|
continue;
|
|
@@ -151,36 +115,17 @@ export const setAuthParams = async ({ security, ...options }) => {
|
|
|
151
115
|
options.headers.set(name, token);
|
|
152
116
|
break;
|
|
153
117
|
}
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
export const buildUrl = (options) => {
|
|
158
|
-
const url = getUrl({
|
|
159
|
-
baseUrl: options.baseUrl,
|
|
160
|
-
path: options.path,
|
|
161
|
-
query: options.query,
|
|
162
|
-
querySerializer: typeof options.querySerializer === 'function'
|
|
163
|
-
? options.querySerializer
|
|
164
|
-
: createQuerySerializer(options.querySerializer),
|
|
165
|
-
url: options.url,
|
|
166
|
-
});
|
|
167
|
-
return url;
|
|
168
|
-
};
|
|
169
|
-
export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
170
|
-
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
171
|
-
let url = (baseUrl ?? '') + pathUrl;
|
|
172
|
-
if (path) {
|
|
173
|
-
url = defaultPathSerializer({ path, url });
|
|
174
|
-
}
|
|
175
|
-
let search = query ? querySerializer(query) : '';
|
|
176
|
-
if (search.startsWith('?')) {
|
|
177
|
-
search = search.substring(1);
|
|
178
|
-
}
|
|
179
|
-
if (search) {
|
|
180
|
-
url += `?${search}`;
|
|
181
118
|
}
|
|
182
|
-
|
|
183
|
-
|
|
119
|
+
}
|
|
120
|
+
export const buildUrl = (options) => getUrl({
|
|
121
|
+
baseUrl: options.baseUrl,
|
|
122
|
+
path: options.path,
|
|
123
|
+
query: options.query,
|
|
124
|
+
querySerializer: typeof options.querySerializer === 'function'
|
|
125
|
+
? options.querySerializer
|
|
126
|
+
: createQuerySerializer(options.querySerializer),
|
|
127
|
+
url: options.url,
|
|
128
|
+
});
|
|
184
129
|
export const mergeConfigs = (a, b) => {
|
|
185
130
|
const config = { ...a, ...b };
|
|
186
131
|
if (config.baseUrl?.endsWith('/')) {
|
|
@@ -189,13 +134,20 @@ export const mergeConfigs = (a, b) => {
|
|
|
189
134
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
190
135
|
return config;
|
|
191
136
|
};
|
|
137
|
+
const headersEntries = (headers) => {
|
|
138
|
+
const entries = [];
|
|
139
|
+
headers.forEach((value, key) => {
|
|
140
|
+
entries.push([key, value]);
|
|
141
|
+
});
|
|
142
|
+
return entries;
|
|
143
|
+
};
|
|
192
144
|
export const mergeHeaders = (...headers) => {
|
|
193
145
|
const mergedHeaders = new Headers();
|
|
194
146
|
for (const header of headers) {
|
|
195
|
-
if (!header
|
|
147
|
+
if (!header) {
|
|
196
148
|
continue;
|
|
197
149
|
}
|
|
198
|
-
const iterator = header instanceof Headers ? header
|
|
150
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
199
151
|
for (const [key, value] of iterator) {
|
|
200
152
|
if (value === null) {
|
|
201
153
|
mergedHeaders.delete(key);
|
|
@@ -206,7 +158,7 @@ export const mergeHeaders = (...headers) => {
|
|
|
206
158
|
}
|
|
207
159
|
}
|
|
208
160
|
else if (value !== undefined) {
|
|
209
|
-
// assume object headers are meant to be JSON stringified, i.e
|
|
161
|
+
// assume object headers are meant to be JSON stringified, i.e., their
|
|
210
162
|
// content value in OpenAPI specification is 'application/json'
|
|
211
163
|
mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
|
|
212
164
|
}
|
|
@@ -215,47 +167,39 @@ export const mergeHeaders = (...headers) => {
|
|
|
215
167
|
return mergedHeaders;
|
|
216
168
|
};
|
|
217
169
|
class Interceptors {
|
|
218
|
-
|
|
219
|
-
constructor() {
|
|
220
|
-
this._fns = [];
|
|
221
|
-
}
|
|
170
|
+
fns = [];
|
|
222
171
|
clear() {
|
|
223
|
-
this.
|
|
172
|
+
this.fns = [];
|
|
224
173
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
else {
|
|
230
|
-
return this._fns.indexOf(id);
|
|
174
|
+
eject(id) {
|
|
175
|
+
const index = this.getInterceptorIndex(id);
|
|
176
|
+
if (this.fns[index]) {
|
|
177
|
+
this.fns[index] = null;
|
|
231
178
|
}
|
|
232
179
|
}
|
|
233
180
|
exists(id) {
|
|
234
181
|
const index = this.getInterceptorIndex(id);
|
|
235
|
-
return
|
|
182
|
+
return Boolean(this.fns[index]);
|
|
236
183
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this._fns[index] = null;
|
|
184
|
+
getInterceptorIndex(id) {
|
|
185
|
+
if (typeof id === 'number') {
|
|
186
|
+
return this.fns[id] ? id : -1;
|
|
241
187
|
}
|
|
188
|
+
return this.fns.indexOf(id);
|
|
242
189
|
}
|
|
243
190
|
update(id, fn) {
|
|
244
191
|
const index = this.getInterceptorIndex(id);
|
|
245
|
-
if (this.
|
|
246
|
-
this.
|
|
192
|
+
if (this.fns[index]) {
|
|
193
|
+
this.fns[index] = fn;
|
|
247
194
|
return id;
|
|
248
195
|
}
|
|
249
|
-
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
196
|
+
return false;
|
|
252
197
|
}
|
|
253
198
|
use(fn) {
|
|
254
|
-
this.
|
|
255
|
-
return this.
|
|
199
|
+
this.fns.push(fn);
|
|
200
|
+
return this.fns.length - 1;
|
|
256
201
|
}
|
|
257
202
|
}
|
|
258
|
-
// do not add `Middleware` as return type so we can use _fns internally
|
|
259
203
|
export const createInterceptors = () => ({
|
|
260
204
|
error: new Interceptors(),
|
|
261
205
|
request: new Interceptors(),
|
package/dist/client.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
1
|
+
import { type ClientOptions, type Config } from './client';
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
3
3
|
/**
|
|
4
4
|
* The `createClientConfig()` function will be called on client initialization
|
|
5
5
|
* and the returned object will become the client's initial configuration.
|
|
@@ -8,5 +8,5 @@ import { type Config, type ClientOptions as DefaultClientOptions } from './clien
|
|
|
8
8
|
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
9
|
* to ensure your client always has the correct values.
|
|
10
10
|
*/
|
|
11
|
-
export type CreateClientConfig<T extends
|
|
11
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
12
|
export declare const client: import("./client").Client;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
|
|
2
|
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
|
+
export type BodySerializer = (body: unknown) => unknown;
|
|
4
|
+
type QuerySerializerOptionsObject = {
|
|
5
|
+
allowReserved?: boolean;
|
|
6
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
7
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
8
|
+
};
|
|
9
|
+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
10
|
+
/**
|
|
11
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
12
|
+
* override the global array/object settings for specific parameter names.
|
|
13
|
+
*/
|
|
14
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
15
|
+
};
|
|
16
|
+
export declare const formDataBodySerializer: {
|
|
17
|
+
bodySerializer: (body: unknown) => FormData;
|
|
18
|
+
};
|
|
19
|
+
export declare const jsonBodySerializer: {
|
|
20
|
+
bodySerializer: (body: unknown) => string;
|
|
21
|
+
};
|
|
22
|
+
export declare const urlSearchParamsBodySerializer: {
|
|
23
|
+
bodySerializer: (body: unknown) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
1
2
|
const serializeFormDataPair = (data, key, value) => {
|
|
2
3
|
if (typeof value === 'string' || value instanceof Blob) {
|
|
3
4
|
data.append(key, value);
|
|
4
5
|
}
|
|
6
|
+
else if (value instanceof Date) {
|
|
7
|
+
data.append(key, value.toISOString());
|
|
8
|
+
}
|
|
5
9
|
else {
|
|
6
10
|
data.append(key, JSON.stringify(value));
|
|
7
11
|
}
|
|
@@ -32,7 +36,7 @@ export const formDataBodySerializer = {
|
|
|
32
36
|
},
|
|
33
37
|
};
|
|
34
38
|
export const jsonBodySerializer = {
|
|
35
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
|
|
39
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
|
|
36
40
|
};
|
|
37
41
|
export const urlSearchParamsBodySerializer = {
|
|
38
42
|
bodySerializer: (body) => {
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
2
2
|
export type Field = {
|
|
3
3
|
in: Exclude<Slot, 'body'>;
|
|
4
|
+
/**
|
|
5
|
+
* Field name. This is the name we want the user to see and use.
|
|
6
|
+
*/
|
|
4
7
|
key: string;
|
|
8
|
+
/**
|
|
9
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
10
|
+
* If omitted, we use the same value as `key`.
|
|
11
|
+
*/
|
|
5
12
|
map?: string;
|
|
6
13
|
} | {
|
|
7
14
|
in: Extract<Slot, 'body'>;
|
|
15
|
+
/**
|
|
16
|
+
* Key isn't required for bodies.
|
|
17
|
+
*/
|
|
8
18
|
key?: string;
|
|
9
19
|
map?: string;
|
|
20
|
+
} | {
|
|
21
|
+
/**
|
|
22
|
+
* Field name. This is the name we want the user to see and use.
|
|
23
|
+
*/
|
|
24
|
+
key: string;
|
|
25
|
+
/**
|
|
26
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
27
|
+
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
28
|
+
*/
|
|
29
|
+
map: Slot;
|
|
10
30
|
};
|
|
11
31
|
export interface Fields {
|
|
12
32
|
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
1
2
|
const extraPrefixesMap = {
|
|
2
3
|
$body_: 'body',
|
|
3
4
|
$headers_: 'headers',
|
|
@@ -18,6 +19,11 @@ const buildKeyMap = (fields, map) => {
|
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
else if ('key' in config) {
|
|
23
|
+
map.set(config.key, {
|
|
24
|
+
map: config.map,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
21
27
|
else if (config.args) {
|
|
22
28
|
buildKeyMap(config.args, map);
|
|
23
29
|
}
|
|
@@ -26,17 +32,17 @@ const buildKeyMap = (fields, map) => {
|
|
|
26
32
|
};
|
|
27
33
|
const stripEmptySlots = (params) => {
|
|
28
34
|
for (const [slot, value] of Object.entries(params)) {
|
|
29
|
-
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
35
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
|
|
30
36
|
delete params[slot];
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
};
|
|
34
40
|
export const buildClientParams = (args, fields) => {
|
|
35
41
|
const params = {
|
|
36
|
-
body:
|
|
37
|
-
headers:
|
|
38
|
-
path:
|
|
39
|
-
query:
|
|
42
|
+
body: Object.create(null),
|
|
43
|
+
headers: Object.create(null),
|
|
44
|
+
path: Object.create(null),
|
|
45
|
+
query: Object.create(null),
|
|
40
46
|
};
|
|
41
47
|
const map = buildKeyMap(fields);
|
|
42
48
|
let config;
|
|
@@ -51,7 +57,9 @@ export const buildClientParams = (args, fields) => {
|
|
|
51
57
|
if (config.key) {
|
|
52
58
|
const field = map.get(config.key);
|
|
53
59
|
const name = field.map || config.key;
|
|
54
|
-
|
|
60
|
+
if (field.in) {
|
|
61
|
+
params[field.in][name] = arg;
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
64
|
else {
|
|
57
65
|
params.body = arg;
|
|
@@ -61,8 +69,13 @@ export const buildClientParams = (args, fields) => {
|
|
|
61
69
|
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
62
70
|
const field = map.get(key);
|
|
63
71
|
if (field) {
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
if (field.in) {
|
|
73
|
+
const name = field.map || key;
|
|
74
|
+
params[field.in][name] = value;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
params[field.map] = value;
|
|
78
|
+
}
|
|
66
79
|
}
|
|
67
80
|
else {
|
|
68
81
|
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
@@ -70,8 +83,8 @@ export const buildClientParams = (args, fields) => {
|
|
|
70
83
|
const [prefix, slot] = extra;
|
|
71
84
|
params[slot][key.slice(prefix.length)] = value;
|
|
72
85
|
}
|
|
73
|
-
else {
|
|
74
|
-
for (const [slot, allowed] of Object.entries(config.allowExtra
|
|
86
|
+
else if ('allowExtra' in config && config.allowExtra) {
|
|
87
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
75
88
|
if (allowed) {
|
|
76
89
|
params[slot][key] = value;
|
|
77
90
|
break;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
1
2
|
export const separatorArrayExplode = (style) => {
|
|
2
3
|
switch (style) {
|
|
3
4
|
case 'label':
|
|
@@ -61,9 +62,7 @@ export const serializeArrayParam = ({ allowReserved, explode, name, style, value
|
|
|
61
62
|
});
|
|
62
63
|
})
|
|
63
64
|
.join(separator);
|
|
64
|
-
return style === 'label' || style === 'matrix'
|
|
65
|
-
? separator + joinedValues
|
|
66
|
-
: joinedValues;
|
|
65
|
+
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
|
67
66
|
};
|
|
68
67
|
export const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
|
|
69
68
|
if (value === undefined || value === null) {
|
|
@@ -81,11 +80,7 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
81
80
|
if (style !== 'deepObject' && !explode) {
|
|
82
81
|
let values = [];
|
|
83
82
|
Object.entries(value).forEach(([key, v]) => {
|
|
84
|
-
values = [
|
|
85
|
-
...values,
|
|
86
|
-
key,
|
|
87
|
-
allowReserved ? v : encodeURIComponent(v),
|
|
88
|
-
];
|
|
83
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
89
84
|
});
|
|
90
85
|
const joinedValues = values.join(',');
|
|
91
86
|
switch (style) {
|
|
@@ -107,7 +102,5 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
107
102
|
value: v,
|
|
108
103
|
}))
|
|
109
104
|
.join(separator);
|
|
110
|
-
return style === 'label' || style === 'matrix'
|
|
111
|
-
? separator + joinedValues
|
|
112
|
-
: joinedValues;
|
|
105
|
+
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
|
113
106
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
3
|
+
*/
|
|
4
|
+
export type JsonValue = null | string | number | boolean | JsonValue[] | {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Safely stringifies a value and parses it back into a JsonValue.
|
|
13
|
+
*/
|
|
14
|
+
export declare const stringifyToJsonValue: (input: unknown) => JsonValue | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
17
|
+
*/
|
|
18
|
+
export declare const serializeQueryKeyValue: (value: unknown) => JsonValue | undefined;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
/**
|
|
3
|
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
4
|
+
*/
|
|
5
|
+
export const queryKeyJsonReplacer = (_key, value) => {
|
|
6
|
+
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === 'bigint') {
|
|
10
|
+
return value.toString();
|
|
11
|
+
}
|
|
12
|
+
if (value instanceof Date) {
|
|
13
|
+
return value.toISOString();
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Safely stringifies a value and parses it back into a JsonValue.
|
|
19
|
+
*/
|
|
20
|
+
export const stringifyToJsonValue = (input) => {
|
|
21
|
+
try {
|
|
22
|
+
const json = JSON.stringify(input, queryKeyJsonReplacer);
|
|
23
|
+
if (json === undefined) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return JSON.parse(json);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Detects plain objects (including objects with a null prototype).
|
|
34
|
+
*/
|
|
35
|
+
const isPlainObject = (value) => {
|
|
36
|
+
if (value === null || typeof value !== 'object') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const prototype = Object.getPrototypeOf(value);
|
|
40
|
+
return prototype === Object.prototype || prototype === null;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
|
44
|
+
*/
|
|
45
|
+
const serializeSearchParams = (params) => {
|
|
46
|
+
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
|
|
47
|
+
const result = {};
|
|
48
|
+
for (const [key, value] of entries) {
|
|
49
|
+
const existing = result[key];
|
|
50
|
+
if (existing === undefined) {
|
|
51
|
+
result[key] = value;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(existing)) {
|
|
55
|
+
existing.push(value);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
result[key] = [existing, value];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
65
|
+
*/
|
|
66
|
+
export const serializeQueryKeyValue = (value) => {
|
|
67
|
+
if (value === null) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (typeof value === 'bigint') {
|
|
77
|
+
return value.toString();
|
|
78
|
+
}
|
|
79
|
+
if (value instanceof Date) {
|
|
80
|
+
return value.toISOString();
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
return stringifyToJsonValue(value);
|
|
84
|
+
}
|
|
85
|
+
if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
|
|
86
|
+
return serializeSearchParams(value);
|
|
87
|
+
}
|
|
88
|
+
if (isPlainObject(value)) {
|
|
89
|
+
return stringifyToJsonValue(value);
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Config } from './types.gen';
|
|
2
|
+
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
5
|
+
* fetch instance.
|
|
6
|
+
*
|
|
7
|
+
* @default globalThis.fetch
|
|
8
|
+
*/
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
/**
|
|
11
|
+
* Implementing clients can call request interceptors inside this hook.
|
|
12
|
+
*/
|
|
13
|
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
14
|
+
/**
|
|
15
|
+
* Callback invoked when a network or parsing error occurs during streaming.
|
|
16
|
+
*
|
|
17
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
18
|
+
*
|
|
19
|
+
* @param error The error that occurred.
|
|
20
|
+
*/
|
|
21
|
+
onSseError?: (error: unknown) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when an event is streamed from the server.
|
|
24
|
+
*
|
|
25
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
26
|
+
*
|
|
27
|
+
* @param event Event streamed from the server.
|
|
28
|
+
* @returns Nothing (void).
|
|
29
|
+
*/
|
|
30
|
+
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
31
|
+
serializedBody?: RequestInit['body'];
|
|
32
|
+
/**
|
|
33
|
+
* Default retry delay in milliseconds.
|
|
34
|
+
*
|
|
35
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
36
|
+
*
|
|
37
|
+
* @default 3000
|
|
38
|
+
*/
|
|
39
|
+
sseDefaultRetryDelay?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum number of retry attempts before giving up.
|
|
42
|
+
*/
|
|
43
|
+
sseMaxRetryAttempts?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum retry delay in milliseconds.
|
|
46
|
+
*
|
|
47
|
+
* Applies only when exponential backoff is used.
|
|
48
|
+
*
|
|
49
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
50
|
+
*
|
|
51
|
+
* @default 30000
|
|
52
|
+
*/
|
|
53
|
+
sseMaxRetryDelay?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Optional sleep function for retry backoff.
|
|
56
|
+
*
|
|
57
|
+
* Defaults to using `setTimeout`.
|
|
58
|
+
*/
|
|
59
|
+
sseSleepFn?: (ms: number) => Promise<void>;
|
|
60
|
+
url: string;
|
|
61
|
+
};
|
|
62
|
+
export interface StreamEvent<TData = unknown> {
|
|
63
|
+
data: TData;
|
|
64
|
+
event?: string;
|
|
65
|
+
id?: string;
|
|
66
|
+
retry?: number;
|
|
67
|
+
}
|
|
68
|
+
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
69
|
+
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
|
70
|
+
};
|
|
71
|
+
export declare function createSseClient<TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions): ServerSentEventsResult<TData>;
|