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