@reverbia/sdk 1.0.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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/cjs/client/client/client.gen.d.ts +2 -0
- package/dist/cjs/client/client/client.gen.js +203 -0
- package/dist/cjs/client/client/index.d.ts +8 -0
- package/dist/cjs/client/client/index.js +16 -0
- package/dist/cjs/client/client/types.gen.d.ts +99 -0
- package/dist/cjs/client/client/types.gen.js +3 -0
- package/dist/cjs/client/client/utils.gen.d.ts +40 -0
- package/dist/cjs/client/client/utils.gen.js +314 -0
- package/dist/cjs/client/client.gen.d.ts +12 -0
- package/dist/cjs/client/client.gen.js +6 -0
- package/dist/cjs/client/core/auth.gen.d.ts +18 -0
- package/dist/cjs/client/core/auth.gen.js +18 -0
- package/dist/cjs/client/core/bodySerializer.gen.d.ts +25 -0
- package/dist/cjs/client/core/bodySerializer.gen.js +60 -0
- package/dist/cjs/client/core/params.gen.d.ts +43 -0
- package/dist/cjs/client/core/params.gen.js +104 -0
- package/dist/cjs/client/core/pathSerializer.gen.d.ts +33 -0
- package/dist/cjs/client/core/pathSerializer.gen.js +123 -0
- package/dist/cjs/client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/cjs/client/core/queryKeySerializer.gen.js +105 -0
- package/dist/cjs/client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/cjs/client/core/serverSentEvents.gen.js +139 -0
- package/dist/cjs/client/core/types.gen.d.ts +78 -0
- package/dist/cjs/client/core/types.gen.js +3 -0
- package/dist/cjs/client/core/utils.gen.d.ts +19 -0
- package/dist/cjs/client/core/utils.gen.js +93 -0
- package/dist/cjs/client/index.d.ts +2 -0
- package/dist/cjs/client/index.js +18 -0
- package/dist/cjs/client/sdk.gen.d.ts +27 -0
- package/dist/cjs/client/sdk.gen.js +33 -0
- package/dist/cjs/client/types.gen.d.ts +120 -0
- package/dist/cjs/client/types.gen.js +3 -0
- package/dist/esm/client/client/client.gen.d.ts +2 -0
- package/dist/esm/client/client/client.gen.js +199 -0
- package/dist/esm/client/client/index.d.ts +8 -0
- package/dist/esm/client/client/index.js +6 -0
- package/dist/esm/client/client/types.gen.d.ts +99 -0
- package/dist/esm/client/client/types.gen.js +2 -0
- package/dist/esm/client/client/utils.gen.d.ts +40 -0
- package/dist/esm/client/client/utils.gen.js +302 -0
- package/dist/esm/client/client.gen.d.ts +12 -0
- package/dist/esm/client/client.gen.js +3 -0
- package/dist/esm/client/core/auth.gen.d.ts +18 -0
- package/dist/esm/client/core/auth.gen.js +14 -0
- package/dist/esm/client/core/bodySerializer.gen.d.ts +25 -0
- package/dist/esm/client/core/bodySerializer.gen.js +57 -0
- package/dist/esm/client/core/params.gen.d.ts +43 -0
- package/dist/esm/client/core/params.gen.js +100 -0
- package/dist/esm/client/core/pathSerializer.gen.d.ts +33 -0
- package/dist/esm/client/core/pathSerializer.gen.js +114 -0
- package/dist/esm/client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/esm/client/core/queryKeySerializer.gen.js +99 -0
- package/dist/esm/client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/esm/client/core/serverSentEvents.gen.js +135 -0
- package/dist/esm/client/core/types.gen.d.ts +78 -0
- package/dist/esm/client/core/types.gen.js +2 -0
- package/dist/esm/client/core/utils.gen.d.ts +19 -0
- package/dist/esm/client/core/utils.gen.js +87 -0
- package/dist/esm/client/index.d.ts +2 -0
- package/dist/esm/client/index.js +2 -0
- package/dist/esm/client/sdk.gen.d.ts +27 -0
- package/dist/esm/client/sdk.gen.js +28 -0
- package/dist/esm/client/types.gen.d.ts +120 -0
- package/dist/esm/client/types.gen.js +2 -0
- package/dist/types/client/client/client.gen.d.ts +2 -0
- package/dist/types/client/client/index.d.ts +8 -0
- package/dist/types/client/client/types.gen.d.ts +99 -0
- package/dist/types/client/client/utils.gen.d.ts +40 -0
- package/dist/types/client/client.gen.d.ts +12 -0
- package/dist/types/client/core/auth.gen.d.ts +18 -0
- package/dist/types/client/core/bodySerializer.gen.d.ts +25 -0
- package/dist/types/client/core/params.gen.d.ts +43 -0
- package/dist/types/client/core/pathSerializer.gen.d.ts +33 -0
- package/dist/types/client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/types/client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/types/client/core/types.gen.d.ts +78 -0
- package/dist/types/client/core/utils.gen.d.ts +19 -0
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/client/sdk.gen.d.ts +27 -0
- package/dist/types/client/types.gen.d.ts +120 -0
- package/package.json +48 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.getUrl = exports.buildUrl = exports.setAuthParams = exports.getParseAs = exports.createQuerySerializer = void 0;
|
|
5
|
+
const auth_gen_1 = require("../core/auth.gen");
|
|
6
|
+
const bodySerializer_gen_1 = require("../core/bodySerializer.gen");
|
|
7
|
+
const pathSerializer_gen_1 = require("../core/pathSerializer.gen");
|
|
8
|
+
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
9
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
10
|
+
let url = _url;
|
|
11
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
12
|
+
if (matches) {
|
|
13
|
+
for (const match of matches) {
|
|
14
|
+
let explode = false;
|
|
15
|
+
let name = match.substring(1, match.length - 1);
|
|
16
|
+
let style = 'simple';
|
|
17
|
+
if (name.endsWith('*')) {
|
|
18
|
+
explode = true;
|
|
19
|
+
name = name.substring(0, name.length - 1);
|
|
20
|
+
}
|
|
21
|
+
if (name.startsWith('.')) {
|
|
22
|
+
name = name.substring(1);
|
|
23
|
+
style = 'label';
|
|
24
|
+
}
|
|
25
|
+
else if (name.startsWith(';')) {
|
|
26
|
+
name = name.substring(1);
|
|
27
|
+
style = 'matrix';
|
|
28
|
+
}
|
|
29
|
+
const value = path[name];
|
|
30
|
+
if (value === undefined || value === null) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
url = url.replace(match, (0, pathSerializer_gen_1.serializeArrayParam)({ explode, name, style, value }));
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === 'object') {
|
|
38
|
+
url = url.replace(match, (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
39
|
+
explode,
|
|
40
|
+
name,
|
|
41
|
+
style,
|
|
42
|
+
value: value,
|
|
43
|
+
valueOnly: true,
|
|
44
|
+
}));
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (style === 'matrix') {
|
|
48
|
+
url = url.replace(match, `;${(0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
49
|
+
name,
|
|
50
|
+
value: value,
|
|
51
|
+
})}`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
|
|
55
|
+
url = url.replace(match, replaceValue);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return url;
|
|
59
|
+
};
|
|
60
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
61
|
+
const querySerializer = (queryParams) => {
|
|
62
|
+
const search = [];
|
|
63
|
+
if (queryParams && typeof queryParams === 'object') {
|
|
64
|
+
for (const name in queryParams) {
|
|
65
|
+
const value = queryParams[name];
|
|
66
|
+
if (value === undefined || value === null) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const options = parameters[name] || args;
|
|
70
|
+
if (Array.isArray(value)) {
|
|
71
|
+
const serializedArray = (0, pathSerializer_gen_1.serializeArrayParam)({
|
|
72
|
+
allowReserved: options.allowReserved,
|
|
73
|
+
explode: true,
|
|
74
|
+
name,
|
|
75
|
+
style: 'form',
|
|
76
|
+
value,
|
|
77
|
+
...options.array,
|
|
78
|
+
});
|
|
79
|
+
if (serializedArray)
|
|
80
|
+
search.push(serializedArray);
|
|
81
|
+
}
|
|
82
|
+
else if (typeof value === 'object') {
|
|
83
|
+
const serializedObject = (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
84
|
+
allowReserved: options.allowReserved,
|
|
85
|
+
explode: true,
|
|
86
|
+
name,
|
|
87
|
+
style: 'deepObject',
|
|
88
|
+
value: value,
|
|
89
|
+
...options.object,
|
|
90
|
+
});
|
|
91
|
+
if (serializedObject)
|
|
92
|
+
search.push(serializedObject);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const serializedPrimitive = (0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
96
|
+
allowReserved: options.allowReserved,
|
|
97
|
+
name,
|
|
98
|
+
value: value,
|
|
99
|
+
});
|
|
100
|
+
if (serializedPrimitive)
|
|
101
|
+
search.push(serializedPrimitive);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return search.join('&');
|
|
106
|
+
};
|
|
107
|
+
return querySerializer;
|
|
108
|
+
};
|
|
109
|
+
exports.createQuerySerializer = createQuerySerializer;
|
|
110
|
+
/**
|
|
111
|
+
* Infers parseAs value from provided Content-Type header.
|
|
112
|
+
*/
|
|
113
|
+
const getParseAs = (contentType) => {
|
|
114
|
+
if (!contentType) {
|
|
115
|
+
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
116
|
+
// which is effectively the same as the 'stream' option.
|
|
117
|
+
return 'stream';
|
|
118
|
+
}
|
|
119
|
+
const cleanContent = contentType.split(';')[0]?.trim();
|
|
120
|
+
if (!cleanContent) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (cleanContent.startsWith('application/json') ||
|
|
124
|
+
cleanContent.endsWith('+json')) {
|
|
125
|
+
return 'json';
|
|
126
|
+
}
|
|
127
|
+
if (cleanContent === 'multipart/form-data') {
|
|
128
|
+
return 'formData';
|
|
129
|
+
}
|
|
130
|
+
if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
|
|
131
|
+
return 'blob';
|
|
132
|
+
}
|
|
133
|
+
if (cleanContent.startsWith('text/')) {
|
|
134
|
+
return 'text';
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
};
|
|
138
|
+
exports.getParseAs = getParseAs;
|
|
139
|
+
const checkForExistence = (options, name) => {
|
|
140
|
+
if (!name) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
if (options.headers.has(name) ||
|
|
144
|
+
options.query?.[name] ||
|
|
145
|
+
options.headers.get('Cookie')?.includes(`${name}=`)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
};
|
|
150
|
+
const setAuthParams = async ({ security, ...options }) => {
|
|
151
|
+
for (const auth of security) {
|
|
152
|
+
if (checkForExistence(options, auth.name)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
|
|
156
|
+
if (!token) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const name = auth.name ?? 'Authorization';
|
|
160
|
+
switch (auth.in) {
|
|
161
|
+
case 'query':
|
|
162
|
+
if (!options.query) {
|
|
163
|
+
options.query = {};
|
|
164
|
+
}
|
|
165
|
+
options.query[name] = token;
|
|
166
|
+
break;
|
|
167
|
+
case 'cookie':
|
|
168
|
+
options.headers.append('Cookie', `${name}=${token}`);
|
|
169
|
+
break;
|
|
170
|
+
case 'header':
|
|
171
|
+
default:
|
|
172
|
+
options.headers.set(name, token);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
exports.setAuthParams = setAuthParams;
|
|
178
|
+
const buildUrl = (options) => {
|
|
179
|
+
const url = (0, exports.getUrl)({
|
|
180
|
+
baseUrl: options.baseUrl,
|
|
181
|
+
path: options.path,
|
|
182
|
+
query: options.query,
|
|
183
|
+
querySerializer: typeof options.querySerializer === 'function'
|
|
184
|
+
? options.querySerializer
|
|
185
|
+
: (0, exports.createQuerySerializer)(options.querySerializer),
|
|
186
|
+
url: options.url,
|
|
187
|
+
});
|
|
188
|
+
return url;
|
|
189
|
+
};
|
|
190
|
+
exports.buildUrl = buildUrl;
|
|
191
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
192
|
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
193
|
+
let url = (baseUrl ?? '') + pathUrl;
|
|
194
|
+
if (path) {
|
|
195
|
+
url = defaultPathSerializer({ path, url });
|
|
196
|
+
}
|
|
197
|
+
let search = query ? querySerializer(query) : '';
|
|
198
|
+
if (search.startsWith('?')) {
|
|
199
|
+
search = search.substring(1);
|
|
200
|
+
}
|
|
201
|
+
if (search) {
|
|
202
|
+
url += `?${search}`;
|
|
203
|
+
}
|
|
204
|
+
return url;
|
|
205
|
+
};
|
|
206
|
+
exports.getUrl = getUrl;
|
|
207
|
+
const mergeConfigs = (a, b) => {
|
|
208
|
+
const config = { ...a, ...b };
|
|
209
|
+
if (config.baseUrl?.endsWith('/')) {
|
|
210
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
211
|
+
}
|
|
212
|
+
config.headers = (0, exports.mergeHeaders)(a.headers, b.headers);
|
|
213
|
+
return config;
|
|
214
|
+
};
|
|
215
|
+
exports.mergeConfigs = mergeConfigs;
|
|
216
|
+
const headersEntries = (headers) => {
|
|
217
|
+
const entries = [];
|
|
218
|
+
headers.forEach((value, key) => {
|
|
219
|
+
entries.push([key, value]);
|
|
220
|
+
});
|
|
221
|
+
return entries;
|
|
222
|
+
};
|
|
223
|
+
const mergeHeaders = (...headers) => {
|
|
224
|
+
const mergedHeaders = new Headers();
|
|
225
|
+
for (const header of headers) {
|
|
226
|
+
if (!header || typeof header !== 'object') {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const iterator = header instanceof Headers
|
|
230
|
+
? headersEntries(header)
|
|
231
|
+
: Object.entries(header);
|
|
232
|
+
for (const [key, value] of iterator) {
|
|
233
|
+
if (value === null) {
|
|
234
|
+
mergedHeaders.delete(key);
|
|
235
|
+
}
|
|
236
|
+
else if (Array.isArray(value)) {
|
|
237
|
+
for (const v of value) {
|
|
238
|
+
mergedHeaders.append(key, v);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (value !== undefined) {
|
|
242
|
+
// assume object headers are meant to be JSON stringified, i.e. their
|
|
243
|
+
// content value in OpenAPI specification is 'application/json'
|
|
244
|
+
mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return mergedHeaders;
|
|
249
|
+
};
|
|
250
|
+
exports.mergeHeaders = mergeHeaders;
|
|
251
|
+
class Interceptors {
|
|
252
|
+
constructor() {
|
|
253
|
+
this.fns = [];
|
|
254
|
+
}
|
|
255
|
+
clear() {
|
|
256
|
+
this.fns = [];
|
|
257
|
+
}
|
|
258
|
+
eject(id) {
|
|
259
|
+
const index = this.getInterceptorIndex(id);
|
|
260
|
+
if (this.fns[index]) {
|
|
261
|
+
this.fns[index] = null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exists(id) {
|
|
265
|
+
const index = this.getInterceptorIndex(id);
|
|
266
|
+
return Boolean(this.fns[index]);
|
|
267
|
+
}
|
|
268
|
+
getInterceptorIndex(id) {
|
|
269
|
+
if (typeof id === 'number') {
|
|
270
|
+
return this.fns[id] ? id : -1;
|
|
271
|
+
}
|
|
272
|
+
return this.fns.indexOf(id);
|
|
273
|
+
}
|
|
274
|
+
update(id, fn) {
|
|
275
|
+
const index = this.getInterceptorIndex(id);
|
|
276
|
+
if (this.fns[index]) {
|
|
277
|
+
this.fns[index] = fn;
|
|
278
|
+
return id;
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
use(fn) {
|
|
283
|
+
this.fns.push(fn);
|
|
284
|
+
return this.fns.length - 1;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const createInterceptors = () => ({
|
|
288
|
+
error: new Interceptors(),
|
|
289
|
+
request: new Interceptors(),
|
|
290
|
+
response: new Interceptors(),
|
|
291
|
+
});
|
|
292
|
+
exports.createInterceptors = createInterceptors;
|
|
293
|
+
const defaultQuerySerializer = (0, exports.createQuerySerializer)({
|
|
294
|
+
allowReserved: false,
|
|
295
|
+
array: {
|
|
296
|
+
explode: true,
|
|
297
|
+
style: 'form',
|
|
298
|
+
},
|
|
299
|
+
object: {
|
|
300
|
+
explode: true,
|
|
301
|
+
style: 'deepObject',
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
const defaultHeaders = {
|
|
305
|
+
'Content-Type': 'application/json',
|
|
306
|
+
};
|
|
307
|
+
const createConfig = (override = {}) => ({
|
|
308
|
+
...bodySerializer_gen_1.jsonBodySerializer,
|
|
309
|
+
headers: defaultHeaders,
|
|
310
|
+
parseAs: 'auto',
|
|
311
|
+
querySerializer: defaultQuerySerializer,
|
|
312
|
+
...override,
|
|
313
|
+
});
|
|
314
|
+
exports.createConfig = createConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ClientOptions, type Config } from './client';
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
3
|
+
/**
|
|
4
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
5
|
+
* and the returned object will become the client's initial configuration.
|
|
6
|
+
*
|
|
7
|
+
* You may want to initialize your client this way instead of calling
|
|
8
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
|
+
* to ensure your client always has the correct values.
|
|
10
|
+
*/
|
|
11
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
|
+
export declare const client: import("./client").Client;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.client = void 0;
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
exports.client = (0, client_1.createClient)((0, client_1.createConfig)());
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AuthToken = string | undefined;
|
|
2
|
+
export interface Auth {
|
|
3
|
+
/**
|
|
4
|
+
* Which part of the request do we use to send the auth?
|
|
5
|
+
*
|
|
6
|
+
* @default 'header'
|
|
7
|
+
*/
|
|
8
|
+
in?: 'header' | 'query' | 'cookie';
|
|
9
|
+
/**
|
|
10
|
+
* Header or query parameter name.
|
|
11
|
+
*
|
|
12
|
+
* @default 'Authorization'
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
scheme?: 'basic' | 'bearer';
|
|
16
|
+
type: 'apiKey' | 'http';
|
|
17
|
+
}
|
|
18
|
+
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getAuthToken = void 0;
|
|
5
|
+
const getAuthToken = async (auth, callback) => {
|
|
6
|
+
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
|
7
|
+
if (!token) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (auth.scheme === 'bearer') {
|
|
11
|
+
return `Bearer ${token}`;
|
|
12
|
+
}
|
|
13
|
+
if (auth.scheme === 'basic') {
|
|
14
|
+
return `Basic ${btoa(token)}`;
|
|
15
|
+
}
|
|
16
|
+
return token;
|
|
17
|
+
};
|
|
18
|
+
exports.getAuthToken = getAuthToken;
|
|
@@ -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: any) => any;
|
|
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: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => FormData;
|
|
18
|
+
};
|
|
19
|
+
export declare const jsonBodySerializer: {
|
|
20
|
+
bodySerializer: <T>(body: T) => string;
|
|
21
|
+
};
|
|
22
|
+
export declare const urlSearchParamsBodySerializer: {
|
|
23
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.urlSearchParamsBodySerializer = exports.jsonBodySerializer = exports.formDataBodySerializer = void 0;
|
|
5
|
+
const serializeFormDataPair = (data, key, value) => {
|
|
6
|
+
if (typeof value === 'string' || value instanceof Blob) {
|
|
7
|
+
data.append(key, value);
|
|
8
|
+
}
|
|
9
|
+
else if (value instanceof Date) {
|
|
10
|
+
data.append(key, value.toISOString());
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
data.append(key, JSON.stringify(value));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
17
|
+
if (typeof value === 'string') {
|
|
18
|
+
data.append(key, value);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
data.append(key, JSON.stringify(value));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.formDataBodySerializer = {
|
|
25
|
+
bodySerializer: (body) => {
|
|
26
|
+
const data = new FormData();
|
|
27
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
28
|
+
if (value === undefined || value === null) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
serializeFormDataPair(data, key, value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return data;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
exports.jsonBodySerializer = {
|
|
42
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
|
|
43
|
+
};
|
|
44
|
+
exports.urlSearchParamsBodySerializer = {
|
|
45
|
+
bodySerializer: (body) => {
|
|
46
|
+
const data = new URLSearchParams();
|
|
47
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
48
|
+
if (value === undefined || value === null) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return data.toString();
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
2
|
+
export type Field = {
|
|
3
|
+
in: Exclude<Slot, 'body'>;
|
|
4
|
+
/**
|
|
5
|
+
* Field name. This is the name we want the user to see and use.
|
|
6
|
+
*/
|
|
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
|
+
*/
|
|
12
|
+
map?: string;
|
|
13
|
+
} | {
|
|
14
|
+
in: Extract<Slot, 'body'>;
|
|
15
|
+
/**
|
|
16
|
+
* Key isn't required for bodies.
|
|
17
|
+
*/
|
|
18
|
+
key?: string;
|
|
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;
|
|
30
|
+
};
|
|
31
|
+
export interface Fields {
|
|
32
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
33
|
+
args?: ReadonlyArray<Field>;
|
|
34
|
+
}
|
|
35
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
36
|
+
interface Params {
|
|
37
|
+
body: unknown;
|
|
38
|
+
headers: Record<string, unknown>;
|
|
39
|
+
path: Record<string, unknown>;
|
|
40
|
+
query: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.buildClientParams = void 0;
|
|
5
|
+
const extraPrefixesMap = {
|
|
6
|
+
$body_: 'body',
|
|
7
|
+
$headers_: 'headers',
|
|
8
|
+
$path_: 'path',
|
|
9
|
+
$query_: 'query',
|
|
10
|
+
};
|
|
11
|
+
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
12
|
+
const buildKeyMap = (fields, map) => {
|
|
13
|
+
if (!map) {
|
|
14
|
+
map = new Map();
|
|
15
|
+
}
|
|
16
|
+
for (const config of fields) {
|
|
17
|
+
if ('in' in config) {
|
|
18
|
+
if (config.key) {
|
|
19
|
+
map.set(config.key, {
|
|
20
|
+
in: config.in,
|
|
21
|
+
map: config.map,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if ('key' in config) {
|
|
26
|
+
map.set(config.key, {
|
|
27
|
+
map: config.map,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else if (config.args) {
|
|
31
|
+
buildKeyMap(config.args, map);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return map;
|
|
35
|
+
};
|
|
36
|
+
const stripEmptySlots = (params) => {
|
|
37
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
38
|
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
39
|
+
delete params[slot];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const buildClientParams = (args, fields) => {
|
|
44
|
+
const params = {
|
|
45
|
+
body: {},
|
|
46
|
+
headers: {},
|
|
47
|
+
path: {},
|
|
48
|
+
query: {},
|
|
49
|
+
};
|
|
50
|
+
const map = buildKeyMap(fields);
|
|
51
|
+
let config;
|
|
52
|
+
for (const [index, arg] of args.entries()) {
|
|
53
|
+
if (fields[index]) {
|
|
54
|
+
config = fields[index];
|
|
55
|
+
}
|
|
56
|
+
if (!config) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if ('in' in config) {
|
|
60
|
+
if (config.key) {
|
|
61
|
+
const field = map.get(config.key);
|
|
62
|
+
const name = field.map || config.key;
|
|
63
|
+
if (field.in) {
|
|
64
|
+
params[field.in][name] = arg;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
params.body = arg;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
73
|
+
const field = map.get(key);
|
|
74
|
+
if (field) {
|
|
75
|
+
if (field.in) {
|
|
76
|
+
const name = field.map || key;
|
|
77
|
+
params[field.in][name] = value;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
params[field.map] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
85
|
+
if (extra) {
|
|
86
|
+
const [prefix, slot] = extra;
|
|
87
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
88
|
+
}
|
|
89
|
+
else if ('allowExtra' in config && config.allowExtra) {
|
|
90
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
91
|
+
if (allowed) {
|
|
92
|
+
params[slot][key] = value;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
stripEmptySlots(params);
|
|
102
|
+
return params;
|
|
103
|
+
};
|
|
104
|
+
exports.buildClientParams = buildClientParams;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {
|
|
2
|
+
}
|
|
3
|
+
interface SerializePrimitiveOptions {
|
|
4
|
+
allowReserved?: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SerializerOptions<T> {
|
|
8
|
+
/**
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
explode: boolean;
|
|
12
|
+
style: T;
|
|
13
|
+
}
|
|
14
|
+
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
15
|
+
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
16
|
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
17
|
+
export type ObjectStyle = 'form' | 'deepObject';
|
|
18
|
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
19
|
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const separatorArrayExplode: (style: ArraySeparatorStyle) => "." | ";" | "," | "&";
|
|
23
|
+
export declare const separatorArrayNoExplode: (style: ArraySeparatorStyle) => "," | "|" | "%20";
|
|
24
|
+
export declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => "." | ";" | "," | "&";
|
|
25
|
+
export declare const serializeArrayParam: ({ allowReserved, explode, name, style, value, }: SerializeOptions<ArraySeparatorStyle> & {
|
|
26
|
+
value: unknown[];
|
|
27
|
+
}) => string;
|
|
28
|
+
export declare const serializePrimitiveParam: ({ allowReserved, name, value, }: SerializePrimitiveParam) => string;
|
|
29
|
+
export declare const serializeObjectParam: ({ allowReserved, explode, name, style, value, valueOnly, }: SerializeOptions<ObjectSeparatorStyle> & {
|
|
30
|
+
value: Record<string, unknown> | Date;
|
|
31
|
+
valueOnly?: boolean;
|
|
32
|
+
}) => string;
|
|
33
|
+
export {};
|