@layer-drone/protocol 0.0.9-alpha.1 → 0.0.9-alpha.2
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/index.d.mts +41 -165
- package/dist/index.d.ts +41 -165
- package/dist/index.js +11 -574
- package/dist/index.mjs +10 -573
- package/package.json +2 -2
- package/src/client/client.gen.ts +3 -2
- package/src/client/index.ts +2 -2
- package/src/client/sdk.gen.ts +92 -130
- package/src/client/transformers.gen.ts +1 -1
- package/src/client/client/client.ts +0 -181
- package/src/client/client/index.ts +0 -22
- package/src/client/client/types.ts +0 -215
- package/src/client/client/utils.ts +0 -415
- package/src/client/core/auth.ts +0 -40
- package/src/client/core/bodySerializer.ts +0 -84
- package/src/client/core/params.ts +0 -141
- package/src/client/core/pathSerializer.ts +0 -179
- package/src/client/core/types.ts +0 -98
package/dist/index.js
CHANGED
|
@@ -50,572 +50,9 @@ __export(index_exports, {
|
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(index_exports);
|
|
52
52
|
|
|
53
|
-
// src/client/core/bodySerializer.ts
|
|
54
|
-
var jsonBodySerializer = {
|
|
55
|
-
bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// src/client/core/params.ts
|
|
59
|
-
var extraPrefixesMap = {
|
|
60
|
-
$body_: "body",
|
|
61
|
-
$headers_: "headers",
|
|
62
|
-
$path_: "path",
|
|
63
|
-
$query_: "query"
|
|
64
|
-
};
|
|
65
|
-
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
66
|
-
|
|
67
|
-
// src/client/core/auth.ts
|
|
68
|
-
var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
|
|
69
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
70
|
-
if (!token) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (auth.scheme === "bearer") {
|
|
74
|
-
return `Bearer ${token}`;
|
|
75
|
-
}
|
|
76
|
-
if (auth.scheme === "basic") {
|
|
77
|
-
return `Basic ${btoa(token)}`;
|
|
78
|
-
}
|
|
79
|
-
return token;
|
|
80
|
-
}, "getAuthToken");
|
|
81
|
-
|
|
82
|
-
// src/client/core/pathSerializer.ts
|
|
83
|
-
var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
|
|
84
|
-
switch (style) {
|
|
85
|
-
case "label":
|
|
86
|
-
return ".";
|
|
87
|
-
case "matrix":
|
|
88
|
-
return ";";
|
|
89
|
-
case "simple":
|
|
90
|
-
return ",";
|
|
91
|
-
default:
|
|
92
|
-
return "&";
|
|
93
|
-
}
|
|
94
|
-
}, "separatorArrayExplode");
|
|
95
|
-
var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
|
|
96
|
-
switch (style) {
|
|
97
|
-
case "form":
|
|
98
|
-
return ",";
|
|
99
|
-
case "pipeDelimited":
|
|
100
|
-
return "|";
|
|
101
|
-
case "spaceDelimited":
|
|
102
|
-
return "%20";
|
|
103
|
-
default:
|
|
104
|
-
return ",";
|
|
105
|
-
}
|
|
106
|
-
}, "separatorArrayNoExplode");
|
|
107
|
-
var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
|
|
108
|
-
switch (style) {
|
|
109
|
-
case "label":
|
|
110
|
-
return ".";
|
|
111
|
-
case "matrix":
|
|
112
|
-
return ";";
|
|
113
|
-
case "simple":
|
|
114
|
-
return ",";
|
|
115
|
-
default:
|
|
116
|
-
return "&";
|
|
117
|
-
}
|
|
118
|
-
}, "separatorObjectExplode");
|
|
119
|
-
var serializeArrayParam = /* @__PURE__ */ __name(({ allowReserved, explode, name, style, value }) => {
|
|
120
|
-
if (!explode) {
|
|
121
|
-
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
122
|
-
switch (style) {
|
|
123
|
-
case "label":
|
|
124
|
-
return `.${joinedValues2}`;
|
|
125
|
-
case "matrix":
|
|
126
|
-
return `;${name}=${joinedValues2}`;
|
|
127
|
-
case "simple":
|
|
128
|
-
return joinedValues2;
|
|
129
|
-
default:
|
|
130
|
-
return `${name}=${joinedValues2}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const separator = separatorArrayExplode(style);
|
|
134
|
-
const joinedValues = value.map((v) => {
|
|
135
|
-
if (style === "label" || style === "simple") {
|
|
136
|
-
return allowReserved ? v : encodeURIComponent(v);
|
|
137
|
-
}
|
|
138
|
-
return serializePrimitiveParam({
|
|
139
|
-
allowReserved,
|
|
140
|
-
name,
|
|
141
|
-
value: v
|
|
142
|
-
});
|
|
143
|
-
}).join(separator);
|
|
144
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
145
|
-
}, "serializeArrayParam");
|
|
146
|
-
var serializePrimitiveParam = /* @__PURE__ */ __name(({ allowReserved, name, value }) => {
|
|
147
|
-
if (value === void 0 || value === null) {
|
|
148
|
-
return "";
|
|
149
|
-
}
|
|
150
|
-
if (typeof value === "object") {
|
|
151
|
-
throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
|
|
152
|
-
}
|
|
153
|
-
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
154
|
-
}, "serializePrimitiveParam");
|
|
155
|
-
var serializeObjectParam = /* @__PURE__ */ __name(({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
156
|
-
if (value instanceof Date) {
|
|
157
|
-
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
158
|
-
}
|
|
159
|
-
if (style !== "deepObject" && !explode) {
|
|
160
|
-
let values = [];
|
|
161
|
-
Object.entries(value).forEach(([key, v]) => {
|
|
162
|
-
values = [
|
|
163
|
-
...values,
|
|
164
|
-
key,
|
|
165
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
166
|
-
];
|
|
167
|
-
});
|
|
168
|
-
const joinedValues2 = values.join(",");
|
|
169
|
-
switch (style) {
|
|
170
|
-
case "form":
|
|
171
|
-
return `${name}=${joinedValues2}`;
|
|
172
|
-
case "label":
|
|
173
|
-
return `.${joinedValues2}`;
|
|
174
|
-
case "matrix":
|
|
175
|
-
return `;${name}=${joinedValues2}`;
|
|
176
|
-
default:
|
|
177
|
-
return joinedValues2;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
const separator = separatorObjectExplode(style);
|
|
181
|
-
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
182
|
-
allowReserved,
|
|
183
|
-
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
184
|
-
value: v
|
|
185
|
-
})).join(separator);
|
|
186
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
187
|
-
}, "serializeObjectParam");
|
|
188
|
-
|
|
189
|
-
// src/client/client/utils.ts
|
|
190
|
-
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
191
|
-
var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
|
|
192
|
-
let url = _url;
|
|
193
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
194
|
-
if (matches) {
|
|
195
|
-
for (const match of matches) {
|
|
196
|
-
let explode = false;
|
|
197
|
-
let name = match.substring(1, match.length - 1);
|
|
198
|
-
let style = "simple";
|
|
199
|
-
if (name.endsWith("*")) {
|
|
200
|
-
explode = true;
|
|
201
|
-
name = name.substring(0, name.length - 1);
|
|
202
|
-
}
|
|
203
|
-
if (name.startsWith(".")) {
|
|
204
|
-
name = name.substring(1);
|
|
205
|
-
style = "label";
|
|
206
|
-
} else if (name.startsWith(";")) {
|
|
207
|
-
name = name.substring(1);
|
|
208
|
-
style = "matrix";
|
|
209
|
-
}
|
|
210
|
-
const value = path[name];
|
|
211
|
-
if (value === void 0 || value === null) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
if (Array.isArray(value)) {
|
|
215
|
-
url = url.replace(match, serializeArrayParam({
|
|
216
|
-
explode,
|
|
217
|
-
name,
|
|
218
|
-
style,
|
|
219
|
-
value
|
|
220
|
-
}));
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
if (typeof value === "object") {
|
|
224
|
-
url = url.replace(match, serializeObjectParam({
|
|
225
|
-
explode,
|
|
226
|
-
name,
|
|
227
|
-
style,
|
|
228
|
-
value,
|
|
229
|
-
valueOnly: true
|
|
230
|
-
}));
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if (style === "matrix") {
|
|
234
|
-
url = url.replace(match, `;${serializePrimitiveParam({
|
|
235
|
-
name,
|
|
236
|
-
value
|
|
237
|
-
})}`);
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
241
|
-
url = url.replace(match, replaceValue);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return url;
|
|
245
|
-
}, "defaultPathSerializer");
|
|
246
|
-
var createQuerySerializer = /* @__PURE__ */ __name(({ allowReserved, array, object } = {}) => {
|
|
247
|
-
const querySerializer = /* @__PURE__ */ __name((queryParams) => {
|
|
248
|
-
const search = [];
|
|
249
|
-
if (queryParams && typeof queryParams === "object") {
|
|
250
|
-
for (const name in queryParams) {
|
|
251
|
-
const value = queryParams[name];
|
|
252
|
-
if (value === void 0 || value === null) {
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if (Array.isArray(value)) {
|
|
256
|
-
const serializedArray = serializeArrayParam({
|
|
257
|
-
allowReserved,
|
|
258
|
-
explode: true,
|
|
259
|
-
name,
|
|
260
|
-
style: "form",
|
|
261
|
-
value,
|
|
262
|
-
...array
|
|
263
|
-
});
|
|
264
|
-
if (serializedArray) search.push(serializedArray);
|
|
265
|
-
} else if (typeof value === "object") {
|
|
266
|
-
const serializedObject = serializeObjectParam({
|
|
267
|
-
allowReserved,
|
|
268
|
-
explode: true,
|
|
269
|
-
name,
|
|
270
|
-
style: "deepObject",
|
|
271
|
-
value,
|
|
272
|
-
...object
|
|
273
|
-
});
|
|
274
|
-
if (serializedObject) search.push(serializedObject);
|
|
275
|
-
} else {
|
|
276
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
277
|
-
allowReserved,
|
|
278
|
-
name,
|
|
279
|
-
value
|
|
280
|
-
});
|
|
281
|
-
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return search.join("&");
|
|
286
|
-
}, "querySerializer");
|
|
287
|
-
return querySerializer;
|
|
288
|
-
}, "createQuerySerializer");
|
|
289
|
-
var getParseAs = /* @__PURE__ */ __name((contentType) => {
|
|
290
|
-
if (!contentType) {
|
|
291
|
-
return "stream";
|
|
292
|
-
}
|
|
293
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
294
|
-
if (!cleanContent) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
298
|
-
return "json";
|
|
299
|
-
}
|
|
300
|
-
if (cleanContent === "multipart/form-data") {
|
|
301
|
-
return "formData";
|
|
302
|
-
}
|
|
303
|
-
if ([
|
|
304
|
-
"application/",
|
|
305
|
-
"audio/",
|
|
306
|
-
"image/",
|
|
307
|
-
"video/"
|
|
308
|
-
].some((type) => cleanContent.startsWith(type))) {
|
|
309
|
-
return "blob";
|
|
310
|
-
}
|
|
311
|
-
if (cleanContent.startsWith("text/")) {
|
|
312
|
-
return "text";
|
|
313
|
-
}
|
|
314
|
-
}, "getParseAs");
|
|
315
|
-
var setAuthParams = /* @__PURE__ */ __name(async ({ security, ...options }) => {
|
|
316
|
-
for (const auth of security) {
|
|
317
|
-
const token = await getAuthToken(auth, options.auth);
|
|
318
|
-
if (!token) {
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const name = auth.name ?? "Authorization";
|
|
322
|
-
switch (auth.in) {
|
|
323
|
-
case "query":
|
|
324
|
-
if (!options.query) {
|
|
325
|
-
options.query = {};
|
|
326
|
-
}
|
|
327
|
-
options.query[name] = token;
|
|
328
|
-
break;
|
|
329
|
-
case "cookie":
|
|
330
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
331
|
-
break;
|
|
332
|
-
case "header":
|
|
333
|
-
default:
|
|
334
|
-
options.headers.set(name, token);
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
}, "setAuthParams");
|
|
340
|
-
var buildUrl = /* @__PURE__ */ __name((options) => {
|
|
341
|
-
const url = getUrl({
|
|
342
|
-
baseUrl: options.baseUrl,
|
|
343
|
-
path: options.path,
|
|
344
|
-
query: options.query,
|
|
345
|
-
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
346
|
-
url: options.url
|
|
347
|
-
});
|
|
348
|
-
return url;
|
|
349
|
-
}, "buildUrl");
|
|
350
|
-
var getUrl = /* @__PURE__ */ __name(({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
351
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
352
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
353
|
-
if (path) {
|
|
354
|
-
url = defaultPathSerializer({
|
|
355
|
-
path,
|
|
356
|
-
url
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
let search = query ? querySerializer(query) : "";
|
|
360
|
-
if (search.startsWith("?")) {
|
|
361
|
-
search = search.substring(1);
|
|
362
|
-
}
|
|
363
|
-
if (search) {
|
|
364
|
-
url += `?${search}`;
|
|
365
|
-
}
|
|
366
|
-
return url;
|
|
367
|
-
}, "getUrl");
|
|
368
|
-
var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
|
|
369
|
-
const config = {
|
|
370
|
-
...a,
|
|
371
|
-
...b
|
|
372
|
-
};
|
|
373
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
374
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
375
|
-
}
|
|
376
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
377
|
-
return config;
|
|
378
|
-
}, "mergeConfigs");
|
|
379
|
-
var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
|
|
380
|
-
const mergedHeaders = new Headers();
|
|
381
|
-
for (const header of headers) {
|
|
382
|
-
if (!header || typeof header !== "object") {
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
|
|
386
|
-
for (const [key, value] of iterator) {
|
|
387
|
-
if (value === null) {
|
|
388
|
-
mergedHeaders.delete(key);
|
|
389
|
-
} else if (Array.isArray(value)) {
|
|
390
|
-
for (const v of value) {
|
|
391
|
-
mergedHeaders.append(key, v);
|
|
392
|
-
}
|
|
393
|
-
} else if (value !== void 0) {
|
|
394
|
-
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
return mergedHeaders;
|
|
399
|
-
}, "mergeHeaders");
|
|
400
|
-
var Interceptors = class Interceptors2 {
|
|
401
|
-
static {
|
|
402
|
-
__name(this, "Interceptors");
|
|
403
|
-
}
|
|
404
|
-
_fns;
|
|
405
|
-
constructor() {
|
|
406
|
-
this._fns = [];
|
|
407
|
-
}
|
|
408
|
-
clear() {
|
|
409
|
-
this._fns = [];
|
|
410
|
-
}
|
|
411
|
-
getInterceptorIndex(id) {
|
|
412
|
-
if (typeof id === "number") {
|
|
413
|
-
return this._fns[id] ? id : -1;
|
|
414
|
-
} else {
|
|
415
|
-
return this._fns.indexOf(id);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
exists(id) {
|
|
419
|
-
const index = this.getInterceptorIndex(id);
|
|
420
|
-
return !!this._fns[index];
|
|
421
|
-
}
|
|
422
|
-
eject(id) {
|
|
423
|
-
const index = this.getInterceptorIndex(id);
|
|
424
|
-
if (this._fns[index]) {
|
|
425
|
-
this._fns[index] = null;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
update(id, fn) {
|
|
429
|
-
const index = this.getInterceptorIndex(id);
|
|
430
|
-
if (this._fns[index]) {
|
|
431
|
-
this._fns[index] = fn;
|
|
432
|
-
return id;
|
|
433
|
-
} else {
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
use(fn) {
|
|
438
|
-
this._fns = [
|
|
439
|
-
...this._fns,
|
|
440
|
-
fn
|
|
441
|
-
];
|
|
442
|
-
return this._fns.length - 1;
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
var createInterceptors = /* @__PURE__ */ __name(() => ({
|
|
446
|
-
error: new Interceptors(),
|
|
447
|
-
request: new Interceptors(),
|
|
448
|
-
response: new Interceptors()
|
|
449
|
-
}), "createInterceptors");
|
|
450
|
-
var defaultQuerySerializer = createQuerySerializer({
|
|
451
|
-
allowReserved: false,
|
|
452
|
-
array: {
|
|
453
|
-
explode: true,
|
|
454
|
-
style: "form"
|
|
455
|
-
},
|
|
456
|
-
object: {
|
|
457
|
-
explode: true,
|
|
458
|
-
style: "deepObject"
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
var defaultHeaders = {
|
|
462
|
-
"Content-Type": "application/json"
|
|
463
|
-
};
|
|
464
|
-
var createConfig = /* @__PURE__ */ __name((override = {}) => ({
|
|
465
|
-
...jsonBodySerializer,
|
|
466
|
-
headers: defaultHeaders,
|
|
467
|
-
parseAs: "auto",
|
|
468
|
-
querySerializer: defaultQuerySerializer,
|
|
469
|
-
...override
|
|
470
|
-
}), "createConfig");
|
|
471
|
-
|
|
472
|
-
// src/client/client/client.ts
|
|
473
|
-
var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
474
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
475
|
-
const getConfig = /* @__PURE__ */ __name(() => ({
|
|
476
|
-
..._config
|
|
477
|
-
}), "getConfig");
|
|
478
|
-
const setConfig = /* @__PURE__ */ __name((config2) => {
|
|
479
|
-
_config = mergeConfigs(_config, config2);
|
|
480
|
-
return getConfig();
|
|
481
|
-
}, "setConfig");
|
|
482
|
-
const interceptors = createInterceptors();
|
|
483
|
-
const request = /* @__PURE__ */ __name(async (options) => {
|
|
484
|
-
const opts = {
|
|
485
|
-
..._config,
|
|
486
|
-
...options,
|
|
487
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
488
|
-
headers: mergeHeaders(_config.headers, options.headers)
|
|
489
|
-
};
|
|
490
|
-
if (opts.security) {
|
|
491
|
-
await setAuthParams({
|
|
492
|
-
...opts,
|
|
493
|
-
security: opts.security
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
if (opts.body && opts.bodySerializer) {
|
|
497
|
-
opts.body = opts.bodySerializer(opts.body);
|
|
498
|
-
}
|
|
499
|
-
if (opts.body === void 0 || opts.body === "") {
|
|
500
|
-
opts.headers.delete("Content-Type");
|
|
501
|
-
}
|
|
502
|
-
const url = buildUrl(opts);
|
|
503
|
-
const requestInit = {
|
|
504
|
-
redirect: "follow",
|
|
505
|
-
...opts
|
|
506
|
-
};
|
|
507
|
-
let request2 = new Request(url, requestInit);
|
|
508
|
-
for (const fn of interceptors.request._fns) {
|
|
509
|
-
if (fn) {
|
|
510
|
-
request2 = await fn(request2, opts);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
const _fetch = opts.fetch;
|
|
514
|
-
let response = await _fetch(request2);
|
|
515
|
-
for (const fn of interceptors.response._fns) {
|
|
516
|
-
if (fn) {
|
|
517
|
-
response = await fn(response, request2, opts);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
const result = {
|
|
521
|
-
request: request2,
|
|
522
|
-
response
|
|
523
|
-
};
|
|
524
|
-
if (response.ok) {
|
|
525
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
526
|
-
return opts.responseStyle === "data" ? {} : {
|
|
527
|
-
data: {},
|
|
528
|
-
...result
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
532
|
-
if (parseAs === "stream") {
|
|
533
|
-
return opts.responseStyle === "data" ? response.body : {
|
|
534
|
-
data: response.body,
|
|
535
|
-
...result
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
let data = await response[parseAs]();
|
|
539
|
-
if (parseAs === "json") {
|
|
540
|
-
if (opts.responseValidator) {
|
|
541
|
-
await opts.responseValidator(data);
|
|
542
|
-
}
|
|
543
|
-
if (opts.responseTransformer) {
|
|
544
|
-
data = await opts.responseTransformer(data);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return opts.responseStyle === "data" ? data : {
|
|
548
|
-
data,
|
|
549
|
-
...result
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
let error = await response.text();
|
|
553
|
-
try {
|
|
554
|
-
error = JSON.parse(error);
|
|
555
|
-
} catch {
|
|
556
|
-
}
|
|
557
|
-
let finalError = error;
|
|
558
|
-
for (const fn of interceptors.error._fns) {
|
|
559
|
-
if (fn) {
|
|
560
|
-
finalError = await fn(error, response, request2, opts);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
finalError = finalError || {};
|
|
564
|
-
if (opts.throwOnError) {
|
|
565
|
-
throw finalError;
|
|
566
|
-
}
|
|
567
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
568
|
-
error: finalError,
|
|
569
|
-
...result
|
|
570
|
-
};
|
|
571
|
-
}, "request");
|
|
572
|
-
return {
|
|
573
|
-
buildUrl,
|
|
574
|
-
connect: /* @__PURE__ */ __name((options) => request({
|
|
575
|
-
...options,
|
|
576
|
-
method: "CONNECT"
|
|
577
|
-
}), "connect"),
|
|
578
|
-
delete: /* @__PURE__ */ __name((options) => request({
|
|
579
|
-
...options,
|
|
580
|
-
method: "DELETE"
|
|
581
|
-
}), "delete"),
|
|
582
|
-
get: /* @__PURE__ */ __name((options) => request({
|
|
583
|
-
...options,
|
|
584
|
-
method: "GET"
|
|
585
|
-
}), "get"),
|
|
586
|
-
getConfig,
|
|
587
|
-
head: /* @__PURE__ */ __name((options) => request({
|
|
588
|
-
...options,
|
|
589
|
-
method: "HEAD"
|
|
590
|
-
}), "head"),
|
|
591
|
-
interceptors,
|
|
592
|
-
options: /* @__PURE__ */ __name((options) => request({
|
|
593
|
-
...options,
|
|
594
|
-
method: "OPTIONS"
|
|
595
|
-
}), "options"),
|
|
596
|
-
patch: /* @__PURE__ */ __name((options) => request({
|
|
597
|
-
...options,
|
|
598
|
-
method: "PATCH"
|
|
599
|
-
}), "patch"),
|
|
600
|
-
post: /* @__PURE__ */ __name((options) => request({
|
|
601
|
-
...options,
|
|
602
|
-
method: "POST"
|
|
603
|
-
}), "post"),
|
|
604
|
-
put: /* @__PURE__ */ __name((options) => request({
|
|
605
|
-
...options,
|
|
606
|
-
method: "PUT"
|
|
607
|
-
}), "put"),
|
|
608
|
-
request,
|
|
609
|
-
setConfig,
|
|
610
|
-
trace: /* @__PURE__ */ __name((options) => request({
|
|
611
|
-
...options,
|
|
612
|
-
method: "TRACE"
|
|
613
|
-
}), "trace")
|
|
614
|
-
};
|
|
615
|
-
}, "createClient");
|
|
616
|
-
|
|
617
53
|
// src/client/client.gen.ts
|
|
618
|
-
var
|
|
54
|
+
var import_client_fetch = require("@hey-api/client-fetch");
|
|
55
|
+
var client = (0, import_client_fetch.createClient)((0, import_client_fetch.createConfig)());
|
|
619
56
|
|
|
620
57
|
// src/client/transformers.gen.ts
|
|
621
58
|
var updateApiTokenResponseDtoSchemaResponseTransformer = /* @__PURE__ */ __name((data) => {
|
|
@@ -664,7 +101,7 @@ var rewardsControllerDepositRewards = /* @__PURE__ */ __name((options) => {
|
|
|
664
101
|
...options,
|
|
665
102
|
headers: {
|
|
666
103
|
"Content-Type": "application/json",
|
|
667
|
-
...options
|
|
104
|
+
...options?.headers
|
|
668
105
|
}
|
|
669
106
|
});
|
|
670
107
|
}, "rewardsControllerDepositRewards");
|
|
@@ -680,7 +117,7 @@ var rewardsControllerDistributeRewards = /* @__PURE__ */ __name((options) => {
|
|
|
680
117
|
...options,
|
|
681
118
|
headers: {
|
|
682
119
|
"Content-Type": "application/json",
|
|
683
|
-
...options
|
|
120
|
+
...options?.headers
|
|
684
121
|
}
|
|
685
122
|
});
|
|
686
123
|
}, "rewardsControllerDistributeRewards");
|
|
@@ -696,7 +133,7 @@ var apiTokenControllerCreateToken = /* @__PURE__ */ __name((options) => {
|
|
|
696
133
|
...options,
|
|
697
134
|
headers: {
|
|
698
135
|
"Content-Type": "application/json",
|
|
699
|
-
...options
|
|
136
|
+
...options?.headers
|
|
700
137
|
}
|
|
701
138
|
});
|
|
702
139
|
}, "apiTokenControllerCreateToken");
|
|
@@ -737,7 +174,7 @@ var apiTokenControllerUpdateToken = /* @__PURE__ */ __name((options) => {
|
|
|
737
174
|
...options,
|
|
738
175
|
headers: {
|
|
739
176
|
"Content-Type": "application/json",
|
|
740
|
-
...options
|
|
177
|
+
...options?.headers
|
|
741
178
|
}
|
|
742
179
|
});
|
|
743
180
|
}, "apiTokenControllerUpdateToken");
|
|
@@ -753,7 +190,7 @@ var quotesControllerCreateQuote = /* @__PURE__ */ __name((options) => {
|
|
|
753
190
|
...options,
|
|
754
191
|
headers: {
|
|
755
192
|
"Content-Type": "application/json",
|
|
756
|
-
...options
|
|
193
|
+
...options?.headers
|
|
757
194
|
}
|
|
758
195
|
});
|
|
759
196
|
}, "quotesControllerCreateQuote");
|
|
@@ -793,7 +230,7 @@ var flightsControllerCreatePresignedUrls = /* @__PURE__ */ __name((options) => {
|
|
|
793
230
|
...options,
|
|
794
231
|
headers: {
|
|
795
232
|
"Content-Type": "application/json",
|
|
796
|
-
...options
|
|
233
|
+
...options?.headers
|
|
797
234
|
}
|
|
798
235
|
});
|
|
799
236
|
}, "flightsControllerCreatePresignedUrls");
|
|
@@ -809,7 +246,7 @@ var flightsControllerValidateFlight = /* @__PURE__ */ __name((options) => {
|
|
|
809
246
|
...options,
|
|
810
247
|
headers: {
|
|
811
248
|
"Content-Type": "application/json",
|
|
812
|
-
...options
|
|
249
|
+
...options?.headers
|
|
813
250
|
}
|
|
814
251
|
});
|
|
815
252
|
}, "flightsControllerValidateFlight");
|
|
@@ -850,7 +287,7 @@ var webhooksControllerCreate = /* @__PURE__ */ __name((options) => {
|
|
|
850
287
|
...options,
|
|
851
288
|
headers: {
|
|
852
289
|
"Content-Type": "application/json",
|
|
853
|
-
...options
|
|
290
|
+
...options?.headers
|
|
854
291
|
}
|
|
855
292
|
});
|
|
856
293
|
}, "webhooksControllerCreate");
|
|
@@ -890,7 +327,7 @@ var webhooksControllerUpdate = /* @__PURE__ */ __name((options) => {
|
|
|
890
327
|
...options,
|
|
891
328
|
headers: {
|
|
892
329
|
"Content-Type": "application/json",
|
|
893
|
-
...options
|
|
330
|
+
...options?.headers
|
|
894
331
|
}
|
|
895
332
|
});
|
|
896
333
|
}, "webhooksControllerUpdate");
|