@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.js CHANGED
@@ -50,572 +50,31 @@ __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 client = createClient(createConfig());
54
+ var import_client_fetch = require("@hey-api/client-fetch");
55
+ var client = (0, import_client_fetch.createClient)((0, import_client_fetch.createConfig)());
56
+
57
+ // src/client/transformers.gen.ts
58
+ var updateApiTokenResponseDtoSchemaResponseTransformer = /* @__PURE__ */ __name((data) => {
59
+ data.deleted_at = new Date(data.deleted_at);
60
+ data.last_used = new Date(data.last_used);
61
+ return data;
62
+ }, "updateApiTokenResponseDtoSchemaResponseTransformer");
63
+ var apiTokenControllerUpdateTokenResponseTransformer = /* @__PURE__ */ __name(async (data) => {
64
+ data = updateApiTokenResponseDtoSchemaResponseTransformer(data);
65
+ return data;
66
+ }, "apiTokenControllerUpdateTokenResponseTransformer");
67
+ var getTimeLimitsForSunAltitudeResponseSchemaResponseTransformer = /* @__PURE__ */ __name((data) => {
68
+ data.OptimalSunAltitudePeriod.StartTime = new Date(data.OptimalSunAltitudePeriod.StartTime);
69
+ data.OptimalSunAltitudePeriod.EndTime = new Date(data.OptimalSunAltitudePeriod.EndTime);
70
+ data.DaylightPeriod.StartTime = new Date(data.DaylightPeriod.StartTime);
71
+ data.DaylightPeriod.EndTime = new Date(data.DaylightPeriod.EndTime);
72
+ return data;
73
+ }, "getTimeLimitsForSunAltitudeResponseSchemaResponseTransformer");
74
+ var conditionsControllerGetSunAltitudeTimeLimitsResponseTransformer = /* @__PURE__ */ __name(async (data) => {
75
+ data = getTimeLimitsForSunAltitudeResponseSchemaResponseTransformer(data);
76
+ return data;
77
+ }, "conditionsControllerGetSunAltitudeTimeLimitsResponseTransformer");
619
78
 
620
79
  // src/client/sdk.gen.ts
621
80
  var appControllerGetHello = /* @__PURE__ */ __name((options) => {
@@ -642,7 +101,7 @@ var rewardsControllerDepositRewards = /* @__PURE__ */ __name((options) => {
642
101
  ...options,
643
102
  headers: {
644
103
  "Content-Type": "application/json",
645
- ...options.headers
104
+ ...options?.headers
646
105
  }
647
106
  });
648
107
  }, "rewardsControllerDepositRewards");
@@ -658,7 +117,7 @@ var rewardsControllerDistributeRewards = /* @__PURE__ */ __name((options) => {
658
117
  ...options,
659
118
  headers: {
660
119
  "Content-Type": "application/json",
661
- ...options.headers
120
+ ...options?.headers
662
121
  }
663
122
  });
664
123
  }, "rewardsControllerDistributeRewards");
@@ -674,7 +133,7 @@ var apiTokenControllerCreateToken = /* @__PURE__ */ __name((options) => {
674
133
  ...options,
675
134
  headers: {
676
135
  "Content-Type": "application/json",
677
- ...options.headers
136
+ ...options?.headers
678
137
  }
679
138
  });
680
139
  }, "apiTokenControllerCreateToken");
@@ -710,11 +169,12 @@ var apiTokenControllerUpdateToken = /* @__PURE__ */ __name((options) => {
710
169
  type: "apiKey"
711
170
  }
712
171
  ],
172
+ responseTransformer: apiTokenControllerUpdateTokenResponseTransformer,
713
173
  url: "/tokens/{id}",
714
174
  ...options,
715
175
  headers: {
716
176
  "Content-Type": "application/json",
717
- ...options.headers
177
+ ...options?.headers
718
178
  }
719
179
  });
720
180
  }, "apiTokenControllerUpdateToken");
@@ -730,7 +190,7 @@ var quotesControllerCreateQuote = /* @__PURE__ */ __name((options) => {
730
190
  ...options,
731
191
  headers: {
732
192
  "Content-Type": "application/json",
733
- ...options.headers
193
+ ...options?.headers
734
194
  }
735
195
  });
736
196
  }, "quotesControllerCreateQuote");
@@ -770,7 +230,7 @@ var flightsControllerCreatePresignedUrls = /* @__PURE__ */ __name((options) => {
770
230
  ...options,
771
231
  headers: {
772
232
  "Content-Type": "application/json",
773
- ...options.headers
233
+ ...options?.headers
774
234
  }
775
235
  });
776
236
  }, "flightsControllerCreatePresignedUrls");
@@ -786,12 +246,13 @@ var flightsControllerValidateFlight = /* @__PURE__ */ __name((options) => {
786
246
  ...options,
787
247
  headers: {
788
248
  "Content-Type": "application/json",
789
- ...options.headers
249
+ ...options?.headers
790
250
  }
791
251
  });
792
252
  }, "flightsControllerValidateFlight");
793
253
  var conditionsControllerGetSunAltitudeTimeLimits = /* @__PURE__ */ __name((options) => {
794
254
  return (options.client ?? client).get({
255
+ responseTransformer: conditionsControllerGetSunAltitudeTimeLimitsResponseTransformer,
795
256
  url: "/conditions/sun-altitude",
796
257
  ...options
797
258
  });
@@ -826,7 +287,7 @@ var webhooksControllerCreate = /* @__PURE__ */ __name((options) => {
826
287
  ...options,
827
288
  headers: {
828
289
  "Content-Type": "application/json",
829
- ...options.headers
290
+ ...options?.headers
830
291
  }
831
292
  });
832
293
  }, "webhooksControllerCreate");
@@ -866,7 +327,7 @@ var webhooksControllerUpdate = /* @__PURE__ */ __name((options) => {
866
327
  ...options,
867
328
  headers: {
868
329
  "Content-Type": "application/json",
869
- ...options.headers
330
+ ...options?.headers
870
331
  }
871
332
  });
872
333
  }, "webhooksControllerUpdate");