@layer-drone/protocol 0.0.9-alpha.2 → 0.0.9-alpha.3
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 +207 -42
- package/dist/index.d.ts +207 -42
- package/dist/index.js +709 -13
- package/dist/index.mjs +701 -11
- package/package.json +4 -4
- package/src/client/client/client.ts +181 -0
- package/src/client/client/index.ts +22 -0
- package/src/client/client/types.ts +215 -0
- package/src/client/client/utils.ts +415 -0
- package/src/client/client.gen.ts +2 -3
- package/src/client/core/auth.ts +40 -0
- package/src/client/core/bodySerializer.ts +84 -0
- package/src/client/core/params.ts +141 -0
- package/src/client/core/pathSerializer.ts +179 -0
- package/src/client/core/types.ts +98 -0
- package/src/client/index.ts +2 -2
- package/src/client/sdk.gen.ts +130 -92
- package/src/client/transformers.gen.ts +1 -1
- package/src/index.ts +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,692 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// src/client/core/bodySerializer.ts
|
|
5
|
+
var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
|
|
6
|
+
if (typeof value === "string" || value instanceof Blob) {
|
|
7
|
+
data.append(key, value);
|
|
8
|
+
} else {
|
|
9
|
+
data.append(key, JSON.stringify(value));
|
|
10
|
+
}
|
|
11
|
+
}, "serializeFormDataPair");
|
|
12
|
+
var serializeUrlSearchParamsPair = /* @__PURE__ */ __name((data, key, value) => {
|
|
13
|
+
if (typeof value === "string") {
|
|
14
|
+
data.append(key, value);
|
|
15
|
+
} else {
|
|
16
|
+
data.append(key, JSON.stringify(value));
|
|
17
|
+
}
|
|
18
|
+
}, "serializeUrlSearchParamsPair");
|
|
19
|
+
var formDataBodySerializer = {
|
|
20
|
+
bodySerializer: /* @__PURE__ */ __name((body) => {
|
|
21
|
+
const data = new FormData();
|
|
22
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
23
|
+
if (value === void 0 || value === null) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
28
|
+
} else {
|
|
29
|
+
serializeFormDataPair(data, key, value);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return data;
|
|
33
|
+
}, "bodySerializer")
|
|
34
|
+
};
|
|
35
|
+
var jsonBodySerializer = {
|
|
36
|
+
bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
|
|
37
|
+
};
|
|
38
|
+
var urlSearchParamsBodySerializer = {
|
|
39
|
+
bodySerializer: /* @__PURE__ */ __name((body) => {
|
|
40
|
+
const data = new URLSearchParams();
|
|
41
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
42
|
+
if (value === void 0 || value === null) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
47
|
+
} else {
|
|
48
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return data.toString();
|
|
52
|
+
}, "bodySerializer")
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/client/core/params.ts
|
|
56
|
+
var extraPrefixesMap = {
|
|
57
|
+
$body_: "body",
|
|
58
|
+
$headers_: "headers",
|
|
59
|
+
$path_: "path",
|
|
60
|
+
$query_: "query"
|
|
61
|
+
};
|
|
62
|
+
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
63
|
+
var buildKeyMap = /* @__PURE__ */ __name((fields, map) => {
|
|
64
|
+
if (!map) {
|
|
65
|
+
map = /* @__PURE__ */ new Map();
|
|
66
|
+
}
|
|
67
|
+
for (const config of fields) {
|
|
68
|
+
if ("in" in config) {
|
|
69
|
+
if (config.key) {
|
|
70
|
+
map.set(config.key, {
|
|
71
|
+
in: config.in,
|
|
72
|
+
map: config.map
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
} else if (config.args) {
|
|
76
|
+
buildKeyMap(config.args, map);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return map;
|
|
80
|
+
}, "buildKeyMap");
|
|
81
|
+
var stripEmptySlots = /* @__PURE__ */ __name((params) => {
|
|
82
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
83
|
+
if (value && typeof value === "object" && !Object.keys(value).length) {
|
|
84
|
+
delete params[slot];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, "stripEmptySlots");
|
|
88
|
+
var buildClientParams = /* @__PURE__ */ __name((args, fields) => {
|
|
89
|
+
const params = {
|
|
90
|
+
body: {},
|
|
91
|
+
headers: {},
|
|
92
|
+
path: {},
|
|
93
|
+
query: {}
|
|
94
|
+
};
|
|
95
|
+
const map = buildKeyMap(fields);
|
|
96
|
+
let config;
|
|
97
|
+
for (const [index, arg] of args.entries()) {
|
|
98
|
+
if (fields[index]) {
|
|
99
|
+
config = fields[index];
|
|
100
|
+
}
|
|
101
|
+
if (!config) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if ("in" in config) {
|
|
105
|
+
if (config.key) {
|
|
106
|
+
const field = map.get(config.key);
|
|
107
|
+
const name = field.map || config.key;
|
|
108
|
+
params[field.in][name] = arg;
|
|
109
|
+
} else {
|
|
110
|
+
params.body = arg;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
114
|
+
const field = map.get(key);
|
|
115
|
+
if (field) {
|
|
116
|
+
const name = field.map || key;
|
|
117
|
+
params[field.in][name] = value;
|
|
118
|
+
} else {
|
|
119
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
120
|
+
if (extra) {
|
|
121
|
+
const [prefix, slot] = extra;
|
|
122
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
123
|
+
} else {
|
|
124
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra ?? {})) {
|
|
125
|
+
if (allowed) {
|
|
126
|
+
params[slot][key] = value;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
stripEmptySlots(params);
|
|
136
|
+
return params;
|
|
137
|
+
}, "buildClientParams");
|
|
138
|
+
|
|
139
|
+
// src/client/core/auth.ts
|
|
140
|
+
var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
|
|
141
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
142
|
+
if (!token) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (auth.scheme === "bearer") {
|
|
146
|
+
return `Bearer ${token}`;
|
|
147
|
+
}
|
|
148
|
+
if (auth.scheme === "basic") {
|
|
149
|
+
return `Basic ${btoa(token)}`;
|
|
150
|
+
}
|
|
151
|
+
return token;
|
|
152
|
+
}, "getAuthToken");
|
|
153
|
+
|
|
154
|
+
// src/client/core/pathSerializer.ts
|
|
155
|
+
var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
|
|
156
|
+
switch (style) {
|
|
157
|
+
case "label":
|
|
158
|
+
return ".";
|
|
159
|
+
case "matrix":
|
|
160
|
+
return ";";
|
|
161
|
+
case "simple":
|
|
162
|
+
return ",";
|
|
163
|
+
default:
|
|
164
|
+
return "&";
|
|
165
|
+
}
|
|
166
|
+
}, "separatorArrayExplode");
|
|
167
|
+
var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
|
|
168
|
+
switch (style) {
|
|
169
|
+
case "form":
|
|
170
|
+
return ",";
|
|
171
|
+
case "pipeDelimited":
|
|
172
|
+
return "|";
|
|
173
|
+
case "spaceDelimited":
|
|
174
|
+
return "%20";
|
|
175
|
+
default:
|
|
176
|
+
return ",";
|
|
177
|
+
}
|
|
178
|
+
}, "separatorArrayNoExplode");
|
|
179
|
+
var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
|
|
180
|
+
switch (style) {
|
|
181
|
+
case "label":
|
|
182
|
+
return ".";
|
|
183
|
+
case "matrix":
|
|
184
|
+
return ";";
|
|
185
|
+
case "simple":
|
|
186
|
+
return ",";
|
|
187
|
+
default:
|
|
188
|
+
return "&";
|
|
189
|
+
}
|
|
190
|
+
}, "separatorObjectExplode");
|
|
191
|
+
var serializeArrayParam = /* @__PURE__ */ __name(({ allowReserved, explode, name, style, value }) => {
|
|
192
|
+
if (!explode) {
|
|
193
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
194
|
+
switch (style) {
|
|
195
|
+
case "label":
|
|
196
|
+
return `.${joinedValues2}`;
|
|
197
|
+
case "matrix":
|
|
198
|
+
return `;${name}=${joinedValues2}`;
|
|
199
|
+
case "simple":
|
|
200
|
+
return joinedValues2;
|
|
201
|
+
default:
|
|
202
|
+
return `${name}=${joinedValues2}`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const separator = separatorArrayExplode(style);
|
|
206
|
+
const joinedValues = value.map((v) => {
|
|
207
|
+
if (style === "label" || style === "simple") {
|
|
208
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
209
|
+
}
|
|
210
|
+
return serializePrimitiveParam({
|
|
211
|
+
allowReserved,
|
|
212
|
+
name,
|
|
213
|
+
value: v
|
|
214
|
+
});
|
|
215
|
+
}).join(separator);
|
|
216
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
217
|
+
}, "serializeArrayParam");
|
|
218
|
+
var serializePrimitiveParam = /* @__PURE__ */ __name(({ allowReserved, name, value }) => {
|
|
219
|
+
if (value === void 0 || value === null) {
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
if (typeof value === "object") {
|
|
223
|
+
throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
|
|
224
|
+
}
|
|
225
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
226
|
+
}, "serializePrimitiveParam");
|
|
227
|
+
var serializeObjectParam = /* @__PURE__ */ __name(({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
228
|
+
if (value instanceof Date) {
|
|
229
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
230
|
+
}
|
|
231
|
+
if (style !== "deepObject" && !explode) {
|
|
232
|
+
let values = [];
|
|
233
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
234
|
+
values = [
|
|
235
|
+
...values,
|
|
236
|
+
key,
|
|
237
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
238
|
+
];
|
|
239
|
+
});
|
|
240
|
+
const joinedValues2 = values.join(",");
|
|
241
|
+
switch (style) {
|
|
242
|
+
case "form":
|
|
243
|
+
return `${name}=${joinedValues2}`;
|
|
244
|
+
case "label":
|
|
245
|
+
return `.${joinedValues2}`;
|
|
246
|
+
case "matrix":
|
|
247
|
+
return `;${name}=${joinedValues2}`;
|
|
248
|
+
default:
|
|
249
|
+
return joinedValues2;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const separator = separatorObjectExplode(style);
|
|
253
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
254
|
+
allowReserved,
|
|
255
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
256
|
+
value: v
|
|
257
|
+
})).join(separator);
|
|
258
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
259
|
+
}, "serializeObjectParam");
|
|
260
|
+
|
|
261
|
+
// src/client/client/utils.ts
|
|
262
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
263
|
+
var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
|
|
264
|
+
let url = _url;
|
|
265
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
266
|
+
if (matches) {
|
|
267
|
+
for (const match of matches) {
|
|
268
|
+
let explode = false;
|
|
269
|
+
let name = match.substring(1, match.length - 1);
|
|
270
|
+
let style = "simple";
|
|
271
|
+
if (name.endsWith("*")) {
|
|
272
|
+
explode = true;
|
|
273
|
+
name = name.substring(0, name.length - 1);
|
|
274
|
+
}
|
|
275
|
+
if (name.startsWith(".")) {
|
|
276
|
+
name = name.substring(1);
|
|
277
|
+
style = "label";
|
|
278
|
+
} else if (name.startsWith(";")) {
|
|
279
|
+
name = name.substring(1);
|
|
280
|
+
style = "matrix";
|
|
281
|
+
}
|
|
282
|
+
const value = path[name];
|
|
283
|
+
if (value === void 0 || value === null) {
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (Array.isArray(value)) {
|
|
287
|
+
url = url.replace(match, serializeArrayParam({
|
|
288
|
+
explode,
|
|
289
|
+
name,
|
|
290
|
+
style,
|
|
291
|
+
value
|
|
292
|
+
}));
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (typeof value === "object") {
|
|
296
|
+
url = url.replace(match, serializeObjectParam({
|
|
297
|
+
explode,
|
|
298
|
+
name,
|
|
299
|
+
style,
|
|
300
|
+
value,
|
|
301
|
+
valueOnly: true
|
|
302
|
+
}));
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (style === "matrix") {
|
|
306
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
307
|
+
name,
|
|
308
|
+
value
|
|
309
|
+
})}`);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
313
|
+
url = url.replace(match, replaceValue);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return url;
|
|
317
|
+
}, "defaultPathSerializer");
|
|
318
|
+
var createQuerySerializer = /* @__PURE__ */ __name(({ allowReserved, array, object } = {}) => {
|
|
319
|
+
const querySerializer = /* @__PURE__ */ __name((queryParams) => {
|
|
320
|
+
const search = [];
|
|
321
|
+
if (queryParams && typeof queryParams === "object") {
|
|
322
|
+
for (const name in queryParams) {
|
|
323
|
+
const value = queryParams[name];
|
|
324
|
+
if (value === void 0 || value === null) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (Array.isArray(value)) {
|
|
328
|
+
const serializedArray = serializeArrayParam({
|
|
329
|
+
allowReserved,
|
|
330
|
+
explode: true,
|
|
331
|
+
name,
|
|
332
|
+
style: "form",
|
|
333
|
+
value,
|
|
334
|
+
...array
|
|
335
|
+
});
|
|
336
|
+
if (serializedArray) search.push(serializedArray);
|
|
337
|
+
} else if (typeof value === "object") {
|
|
338
|
+
const serializedObject = serializeObjectParam({
|
|
339
|
+
allowReserved,
|
|
340
|
+
explode: true,
|
|
341
|
+
name,
|
|
342
|
+
style: "deepObject",
|
|
343
|
+
value,
|
|
344
|
+
...object
|
|
345
|
+
});
|
|
346
|
+
if (serializedObject) search.push(serializedObject);
|
|
347
|
+
} else {
|
|
348
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
349
|
+
allowReserved,
|
|
350
|
+
name,
|
|
351
|
+
value
|
|
352
|
+
});
|
|
353
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return search.join("&");
|
|
358
|
+
}, "querySerializer");
|
|
359
|
+
return querySerializer;
|
|
360
|
+
}, "createQuerySerializer");
|
|
361
|
+
var getParseAs = /* @__PURE__ */ __name((contentType) => {
|
|
362
|
+
if (!contentType) {
|
|
363
|
+
return "stream";
|
|
364
|
+
}
|
|
365
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
366
|
+
if (!cleanContent) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
370
|
+
return "json";
|
|
371
|
+
}
|
|
372
|
+
if (cleanContent === "multipart/form-data") {
|
|
373
|
+
return "formData";
|
|
374
|
+
}
|
|
375
|
+
if ([
|
|
376
|
+
"application/",
|
|
377
|
+
"audio/",
|
|
378
|
+
"image/",
|
|
379
|
+
"video/"
|
|
380
|
+
].some((type) => cleanContent.startsWith(type))) {
|
|
381
|
+
return "blob";
|
|
382
|
+
}
|
|
383
|
+
if (cleanContent.startsWith("text/")) {
|
|
384
|
+
return "text";
|
|
385
|
+
}
|
|
386
|
+
}, "getParseAs");
|
|
387
|
+
var setAuthParams = /* @__PURE__ */ __name(async ({ security, ...options }) => {
|
|
388
|
+
for (const auth of security) {
|
|
389
|
+
const token = await getAuthToken(auth, options.auth);
|
|
390
|
+
if (!token) {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
const name = auth.name ?? "Authorization";
|
|
394
|
+
switch (auth.in) {
|
|
395
|
+
case "query":
|
|
396
|
+
if (!options.query) {
|
|
397
|
+
options.query = {};
|
|
398
|
+
}
|
|
399
|
+
options.query[name] = token;
|
|
400
|
+
break;
|
|
401
|
+
case "cookie":
|
|
402
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
403
|
+
break;
|
|
404
|
+
case "header":
|
|
405
|
+
default:
|
|
406
|
+
options.headers.set(name, token);
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
}, "setAuthParams");
|
|
412
|
+
var buildUrl = /* @__PURE__ */ __name((options) => {
|
|
413
|
+
const url = getUrl({
|
|
414
|
+
baseUrl: options.baseUrl,
|
|
415
|
+
path: options.path,
|
|
416
|
+
query: options.query,
|
|
417
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
418
|
+
url: options.url
|
|
419
|
+
});
|
|
420
|
+
return url;
|
|
421
|
+
}, "buildUrl");
|
|
422
|
+
var getUrl = /* @__PURE__ */ __name(({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
423
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
424
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
425
|
+
if (path) {
|
|
426
|
+
url = defaultPathSerializer({
|
|
427
|
+
path,
|
|
428
|
+
url
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
let search = query ? querySerializer(query) : "";
|
|
432
|
+
if (search.startsWith("?")) {
|
|
433
|
+
search = search.substring(1);
|
|
434
|
+
}
|
|
435
|
+
if (search) {
|
|
436
|
+
url += `?${search}`;
|
|
437
|
+
}
|
|
438
|
+
return url;
|
|
439
|
+
}, "getUrl");
|
|
440
|
+
var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
|
|
441
|
+
const config = {
|
|
442
|
+
...a,
|
|
443
|
+
...b
|
|
444
|
+
};
|
|
445
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
446
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
447
|
+
}
|
|
448
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
449
|
+
return config;
|
|
450
|
+
}, "mergeConfigs");
|
|
451
|
+
var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
|
|
452
|
+
const mergedHeaders = new Headers();
|
|
453
|
+
for (const header of headers) {
|
|
454
|
+
if (!header || typeof header !== "object") {
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
|
|
458
|
+
for (const [key, value] of iterator) {
|
|
459
|
+
if (value === null) {
|
|
460
|
+
mergedHeaders.delete(key);
|
|
461
|
+
} else if (Array.isArray(value)) {
|
|
462
|
+
for (const v of value) {
|
|
463
|
+
mergedHeaders.append(key, v);
|
|
464
|
+
}
|
|
465
|
+
} else if (value !== void 0) {
|
|
466
|
+
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return mergedHeaders;
|
|
471
|
+
}, "mergeHeaders");
|
|
472
|
+
var Interceptors = class Interceptors2 {
|
|
473
|
+
static {
|
|
474
|
+
__name(this, "Interceptors");
|
|
475
|
+
}
|
|
476
|
+
_fns;
|
|
477
|
+
constructor() {
|
|
478
|
+
this._fns = [];
|
|
479
|
+
}
|
|
480
|
+
clear() {
|
|
481
|
+
this._fns = [];
|
|
482
|
+
}
|
|
483
|
+
getInterceptorIndex(id) {
|
|
484
|
+
if (typeof id === "number") {
|
|
485
|
+
return this._fns[id] ? id : -1;
|
|
486
|
+
} else {
|
|
487
|
+
return this._fns.indexOf(id);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
exists(id) {
|
|
491
|
+
const index = this.getInterceptorIndex(id);
|
|
492
|
+
return !!this._fns[index];
|
|
493
|
+
}
|
|
494
|
+
eject(id) {
|
|
495
|
+
const index = this.getInterceptorIndex(id);
|
|
496
|
+
if (this._fns[index]) {
|
|
497
|
+
this._fns[index] = null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
update(id, fn) {
|
|
501
|
+
const index = this.getInterceptorIndex(id);
|
|
502
|
+
if (this._fns[index]) {
|
|
503
|
+
this._fns[index] = fn;
|
|
504
|
+
return id;
|
|
505
|
+
} else {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
use(fn) {
|
|
510
|
+
this._fns = [
|
|
511
|
+
...this._fns,
|
|
512
|
+
fn
|
|
513
|
+
];
|
|
514
|
+
return this._fns.length - 1;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
var createInterceptors = /* @__PURE__ */ __name(() => ({
|
|
518
|
+
error: new Interceptors(),
|
|
519
|
+
request: new Interceptors(),
|
|
520
|
+
response: new Interceptors()
|
|
521
|
+
}), "createInterceptors");
|
|
522
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
523
|
+
allowReserved: false,
|
|
524
|
+
array: {
|
|
525
|
+
explode: true,
|
|
526
|
+
style: "form"
|
|
527
|
+
},
|
|
528
|
+
object: {
|
|
529
|
+
explode: true,
|
|
530
|
+
style: "deepObject"
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
var defaultHeaders = {
|
|
534
|
+
"Content-Type": "application/json"
|
|
535
|
+
};
|
|
536
|
+
var createConfig = /* @__PURE__ */ __name((override = {}) => ({
|
|
537
|
+
...jsonBodySerializer,
|
|
538
|
+
headers: defaultHeaders,
|
|
539
|
+
parseAs: "auto",
|
|
540
|
+
querySerializer: defaultQuerySerializer,
|
|
541
|
+
...override
|
|
542
|
+
}), "createConfig");
|
|
543
|
+
|
|
544
|
+
// src/client/client/client.ts
|
|
545
|
+
var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
546
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
547
|
+
const getConfig = /* @__PURE__ */ __name(() => ({
|
|
548
|
+
..._config
|
|
549
|
+
}), "getConfig");
|
|
550
|
+
const setConfig = /* @__PURE__ */ __name((config2) => {
|
|
551
|
+
_config = mergeConfigs(_config, config2);
|
|
552
|
+
return getConfig();
|
|
553
|
+
}, "setConfig");
|
|
554
|
+
const interceptors = createInterceptors();
|
|
555
|
+
const request = /* @__PURE__ */ __name(async (options) => {
|
|
556
|
+
const opts = {
|
|
557
|
+
..._config,
|
|
558
|
+
...options,
|
|
559
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
560
|
+
headers: mergeHeaders(_config.headers, options.headers)
|
|
561
|
+
};
|
|
562
|
+
if (opts.security) {
|
|
563
|
+
await setAuthParams({
|
|
564
|
+
...opts,
|
|
565
|
+
security: opts.security
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
if (opts.body && opts.bodySerializer) {
|
|
569
|
+
opts.body = opts.bodySerializer(opts.body);
|
|
570
|
+
}
|
|
571
|
+
if (opts.body === void 0 || opts.body === "") {
|
|
572
|
+
opts.headers.delete("Content-Type");
|
|
573
|
+
}
|
|
574
|
+
const url = buildUrl(opts);
|
|
575
|
+
const requestInit = {
|
|
576
|
+
redirect: "follow",
|
|
577
|
+
...opts
|
|
578
|
+
};
|
|
579
|
+
let request2 = new Request(url, requestInit);
|
|
580
|
+
for (const fn of interceptors.request._fns) {
|
|
581
|
+
if (fn) {
|
|
582
|
+
request2 = await fn(request2, opts);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const _fetch = opts.fetch;
|
|
586
|
+
let response = await _fetch(request2);
|
|
587
|
+
for (const fn of interceptors.response._fns) {
|
|
588
|
+
if (fn) {
|
|
589
|
+
response = await fn(response, request2, opts);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const result = {
|
|
593
|
+
request: request2,
|
|
594
|
+
response
|
|
595
|
+
};
|
|
596
|
+
if (response.ok) {
|
|
597
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
598
|
+
return opts.responseStyle === "data" ? {} : {
|
|
599
|
+
data: {},
|
|
600
|
+
...result
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
604
|
+
if (parseAs === "stream") {
|
|
605
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
606
|
+
data: response.body,
|
|
607
|
+
...result
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
let data = await response[parseAs]();
|
|
611
|
+
if (parseAs === "json") {
|
|
612
|
+
if (opts.responseValidator) {
|
|
613
|
+
await opts.responseValidator(data);
|
|
614
|
+
}
|
|
615
|
+
if (opts.responseTransformer) {
|
|
616
|
+
data = await opts.responseTransformer(data);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return opts.responseStyle === "data" ? data : {
|
|
620
|
+
data,
|
|
621
|
+
...result
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
let error = await response.text();
|
|
625
|
+
try {
|
|
626
|
+
error = JSON.parse(error);
|
|
627
|
+
} catch {
|
|
628
|
+
}
|
|
629
|
+
let finalError = error;
|
|
630
|
+
for (const fn of interceptors.error._fns) {
|
|
631
|
+
if (fn) {
|
|
632
|
+
finalError = await fn(error, response, request2, opts);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
finalError = finalError || {};
|
|
636
|
+
if (opts.throwOnError) {
|
|
637
|
+
throw finalError;
|
|
638
|
+
}
|
|
639
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
640
|
+
error: finalError,
|
|
641
|
+
...result
|
|
642
|
+
};
|
|
643
|
+
}, "request");
|
|
644
|
+
return {
|
|
645
|
+
buildUrl,
|
|
646
|
+
connect: /* @__PURE__ */ __name((options) => request({
|
|
647
|
+
...options,
|
|
648
|
+
method: "CONNECT"
|
|
649
|
+
}), "connect"),
|
|
650
|
+
delete: /* @__PURE__ */ __name((options) => request({
|
|
651
|
+
...options,
|
|
652
|
+
method: "DELETE"
|
|
653
|
+
}), "delete"),
|
|
654
|
+
get: /* @__PURE__ */ __name((options) => request({
|
|
655
|
+
...options,
|
|
656
|
+
method: "GET"
|
|
657
|
+
}), "get"),
|
|
658
|
+
getConfig,
|
|
659
|
+
head: /* @__PURE__ */ __name((options) => request({
|
|
660
|
+
...options,
|
|
661
|
+
method: "HEAD"
|
|
662
|
+
}), "head"),
|
|
663
|
+
interceptors,
|
|
664
|
+
options: /* @__PURE__ */ __name((options) => request({
|
|
665
|
+
...options,
|
|
666
|
+
method: "OPTIONS"
|
|
667
|
+
}), "options"),
|
|
668
|
+
patch: /* @__PURE__ */ __name((options) => request({
|
|
669
|
+
...options,
|
|
670
|
+
method: "PATCH"
|
|
671
|
+
}), "patch"),
|
|
672
|
+
post: /* @__PURE__ */ __name((options) => request({
|
|
673
|
+
...options,
|
|
674
|
+
method: "POST"
|
|
675
|
+
}), "post"),
|
|
676
|
+
put: /* @__PURE__ */ __name((options) => request({
|
|
677
|
+
...options,
|
|
678
|
+
method: "PUT"
|
|
679
|
+
}), "put"),
|
|
680
|
+
request,
|
|
681
|
+
setConfig,
|
|
682
|
+
trace: /* @__PURE__ */ __name((options) => request({
|
|
683
|
+
...options,
|
|
684
|
+
method: "TRACE"
|
|
685
|
+
}), "trace")
|
|
686
|
+
};
|
|
687
|
+
}, "createClient");
|
|
688
|
+
|
|
4
689
|
// src/client/client.gen.ts
|
|
5
|
-
import { createClient, createConfig } from "@hey-api/client-fetch";
|
|
6
690
|
var client = createClient(createConfig());
|
|
7
691
|
|
|
8
692
|
// src/client/transformers.gen.ts
|
|
@@ -52,7 +736,7 @@ var rewardsControllerDepositRewards = /* @__PURE__ */ __name((options) => {
|
|
|
52
736
|
...options,
|
|
53
737
|
headers: {
|
|
54
738
|
"Content-Type": "application/json",
|
|
55
|
-
...options
|
|
739
|
+
...options.headers
|
|
56
740
|
}
|
|
57
741
|
});
|
|
58
742
|
}, "rewardsControllerDepositRewards");
|
|
@@ -68,7 +752,7 @@ var rewardsControllerDistributeRewards = /* @__PURE__ */ __name((options) => {
|
|
|
68
752
|
...options,
|
|
69
753
|
headers: {
|
|
70
754
|
"Content-Type": "application/json",
|
|
71
|
-
...options
|
|
755
|
+
...options.headers
|
|
72
756
|
}
|
|
73
757
|
});
|
|
74
758
|
}, "rewardsControllerDistributeRewards");
|
|
@@ -84,7 +768,7 @@ var apiTokenControllerCreateToken = /* @__PURE__ */ __name((options) => {
|
|
|
84
768
|
...options,
|
|
85
769
|
headers: {
|
|
86
770
|
"Content-Type": "application/json",
|
|
87
|
-
...options
|
|
771
|
+
...options.headers
|
|
88
772
|
}
|
|
89
773
|
});
|
|
90
774
|
}, "apiTokenControllerCreateToken");
|
|
@@ -125,7 +809,7 @@ var apiTokenControllerUpdateToken = /* @__PURE__ */ __name((options) => {
|
|
|
125
809
|
...options,
|
|
126
810
|
headers: {
|
|
127
811
|
"Content-Type": "application/json",
|
|
128
|
-
...options
|
|
812
|
+
...options.headers
|
|
129
813
|
}
|
|
130
814
|
});
|
|
131
815
|
}, "apiTokenControllerUpdateToken");
|
|
@@ -141,7 +825,7 @@ var quotesControllerCreateQuote = /* @__PURE__ */ __name((options) => {
|
|
|
141
825
|
...options,
|
|
142
826
|
headers: {
|
|
143
827
|
"Content-Type": "application/json",
|
|
144
|
-
...options
|
|
828
|
+
...options.headers
|
|
145
829
|
}
|
|
146
830
|
});
|
|
147
831
|
}, "quotesControllerCreateQuote");
|
|
@@ -181,7 +865,7 @@ var flightsControllerCreatePresignedUrls = /* @__PURE__ */ __name((options) => {
|
|
|
181
865
|
...options,
|
|
182
866
|
headers: {
|
|
183
867
|
"Content-Type": "application/json",
|
|
184
|
-
...options
|
|
868
|
+
...options.headers
|
|
185
869
|
}
|
|
186
870
|
});
|
|
187
871
|
}, "flightsControllerCreatePresignedUrls");
|
|
@@ -197,7 +881,7 @@ var flightsControllerValidateFlight = /* @__PURE__ */ __name((options) => {
|
|
|
197
881
|
...options,
|
|
198
882
|
headers: {
|
|
199
883
|
"Content-Type": "application/json",
|
|
200
|
-
...options
|
|
884
|
+
...options.headers
|
|
201
885
|
}
|
|
202
886
|
});
|
|
203
887
|
}, "flightsControllerValidateFlight");
|
|
@@ -238,7 +922,7 @@ var webhooksControllerCreate = /* @__PURE__ */ __name((options) => {
|
|
|
238
922
|
...options,
|
|
239
923
|
headers: {
|
|
240
924
|
"Content-Type": "application/json",
|
|
241
|
-
...options
|
|
925
|
+
...options.headers
|
|
242
926
|
}
|
|
243
927
|
});
|
|
244
928
|
}, "webhooksControllerCreate");
|
|
@@ -278,7 +962,7 @@ var webhooksControllerUpdate = /* @__PURE__ */ __name((options) => {
|
|
|
278
962
|
...options,
|
|
279
963
|
headers: {
|
|
280
964
|
"Content-Type": "application/json",
|
|
281
|
-
...options
|
|
965
|
+
...options.headers
|
|
282
966
|
}
|
|
283
967
|
});
|
|
284
968
|
}, "webhooksControllerUpdate");
|
|
@@ -373,18 +1057,24 @@ export {
|
|
|
373
1057
|
apiTokenControllerGetToken,
|
|
374
1058
|
apiTokenControllerUpdateToken,
|
|
375
1059
|
appControllerGetHello,
|
|
376
|
-
|
|
1060
|
+
buildClientParams,
|
|
377
1061
|
conditionsControllerGetSunAltitudeTimeLimits,
|
|
1062
|
+
createClient,
|
|
1063
|
+
createConfig,
|
|
378
1064
|
flightsControllerCreatePresignedUrls,
|
|
379
1065
|
flightsControllerGenerateFlightId,
|
|
380
1066
|
flightsControllerValidateFlight,
|
|
1067
|
+
formDataBodySerializer,
|
|
1068
|
+
jsonBodySerializer,
|
|
381
1069
|
keysControllerGetProvenanceCryptoKey,
|
|
1070
|
+
mergeHeaders,
|
|
382
1071
|
parseWebhookEvent,
|
|
383
1072
|
quotesControllerCreateQuote,
|
|
384
1073
|
quotesControllerGetQuote,
|
|
385
1074
|
rewardsControllerDepositRewards,
|
|
386
1075
|
rewardsControllerDistributeRewards,
|
|
387
1076
|
schemaControllerGetEventSchema,
|
|
1077
|
+
urlSearchParamsBodySerializer,
|
|
388
1078
|
webhooksControllerCreate,
|
|
389
1079
|
webhooksControllerDelete,
|
|
390
1080
|
webhooksControllerGet,
|