@layer-drone/protocol 0.0.17 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/index.d.mts +328 -347
- package/dist/index.d.ts +328 -347
- package/dist/index.js +106 -123
- package/dist/index.mjs +105 -121
- package/package.json +7 -2
- package/src/client/client/client.ts +5 -1
- package/src/client/sdk.gen.ts +108 -136
- package/src/client/transformers.gen.ts +12 -26
- package/src/client/types.gen.ts +219 -262
- package/src/event/types.gen.ts +40 -41
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
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@hey-api/openapi-ts": "^0.74.0",
|
|
20
20
|
"@types/express": "^4",
|
|
21
|
+
"@types/jest": "^29.5.2",
|
|
21
22
|
"@types/node": "^20.3.1",
|
|
22
23
|
"express": "^4",
|
|
24
|
+
"jest": "^29.7.0",
|
|
23
25
|
"json-schema-to-zod": "^2.6.1",
|
|
26
|
+
"ts-jest": "^29.2.5",
|
|
24
27
|
"ts-loader": "^9.4.3",
|
|
25
28
|
"ts-node": "^10.9.2",
|
|
26
29
|
"tsup": "^8.5.0",
|
|
@@ -40,6 +43,8 @@
|
|
|
40
43
|
"generate-event": "ts-node ./scripts/generate-event-type.ts",
|
|
41
44
|
"generate": "pnpm generate-api && pnpm generate-event && pnpm lint --fix && pnpm build",
|
|
42
45
|
"type-check": "tsc --noEmit",
|
|
43
|
-
"
|
|
46
|
+
"test": "jest",
|
|
47
|
+
"test:watch": "jest --watch",
|
|
48
|
+
"coverage": "jest --coverage"
|
|
44
49
|
}
|
|
45
50
|
}
|
|
@@ -55,7 +55,11 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
55
55
|
opts.headers.delete("Content-Type");
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const url = buildUrl(
|
|
58
|
+
const url = buildUrl({
|
|
59
|
+
...opts,
|
|
60
|
+
baseUrl: opts.baseUrl ?? _config?.baseUrl ?? "https://api.layerdrone.org",
|
|
61
|
+
url: opts.url ?? "",
|
|
62
|
+
});
|
|
59
63
|
const requestInit: ReqInit = {
|
|
60
64
|
redirect: "follow",
|
|
61
65
|
...opts,
|
package/src/client/sdk.gen.ts
CHANGED
|
@@ -8,10 +8,11 @@ import type {
|
|
|
8
8
|
import {
|
|
9
9
|
apiTokenControllerUpdateTokenResponseTransformer,
|
|
10
10
|
conditionsControllerGetSunAltitudeTimeLimitsResponseTransformer,
|
|
11
|
-
flightsControllerGetFlightResponseTransformer,
|
|
12
11
|
flightsControllerValidateFlightResponseTransformer,
|
|
13
12
|
} from "./transformers.gen.js";
|
|
14
13
|
import type {
|
|
14
|
+
ApiControllerGetHelloData,
|
|
15
|
+
ApiControllerGetHelloResponses,
|
|
15
16
|
ApiTokenControllerCreateTokenData,
|
|
16
17
|
ApiTokenControllerCreateTokenErrors,
|
|
17
18
|
ApiTokenControllerCreateTokenResponses,
|
|
@@ -24,8 +25,6 @@ import type {
|
|
|
24
25
|
ApiTokenControllerUpdateTokenData,
|
|
25
26
|
ApiTokenControllerUpdateTokenErrors,
|
|
26
27
|
ApiTokenControllerUpdateTokenResponses,
|
|
27
|
-
AppControllerGetHelloData,
|
|
28
|
-
AppControllerGetHelloResponses,
|
|
29
28
|
ConditionsControllerGetSunAltitudeTimeLimitsData,
|
|
30
29
|
ConditionsControllerGetSunAltitudeTimeLimitsResponses,
|
|
31
30
|
FlightsControllerCreatePresignedUrlsData,
|
|
@@ -42,9 +41,6 @@ import type {
|
|
|
42
41
|
FlightsControllerValidateFlightResponses,
|
|
43
42
|
KeysControllerGetProvenanceCryptoKeyData,
|
|
44
43
|
KeysControllerGetProvenanceCryptoKeyResponses,
|
|
45
|
-
MissionsControllerClaimRewardsData,
|
|
46
|
-
MissionsControllerClaimRewardsErrors,
|
|
47
|
-
MissionsControllerClaimRewardsResponses,
|
|
48
44
|
MissionsControllerCreateMissionsData,
|
|
49
45
|
MissionsControllerCreateMissionsErrors,
|
|
50
46
|
MissionsControllerCreateMissionsResponses,
|
|
@@ -101,11 +97,11 @@ export type Options<
|
|
|
101
97
|
meta?: Record<string, unknown>;
|
|
102
98
|
};
|
|
103
99
|
|
|
104
|
-
export const
|
|
105
|
-
options?: Options<
|
|
100
|
+
export const apiControllerGetHello = <ThrowOnError extends boolean = false>(
|
|
101
|
+
options?: Options<ApiControllerGetHelloData, ThrowOnError>,
|
|
106
102
|
) => {
|
|
107
103
|
return (options?.client ?? _heyApiClient).get<
|
|
108
|
-
|
|
104
|
+
ApiControllerGetHelloResponses,
|
|
109
105
|
unknown,
|
|
110
106
|
ThrowOnError
|
|
111
107
|
>({
|
|
@@ -114,65 +110,6 @@ export const appControllerGetHello = <ThrowOnError extends boolean = false>(
|
|
|
114
110
|
});
|
|
115
111
|
};
|
|
116
112
|
|
|
117
|
-
export const keysControllerGetProvenanceCryptoKey = <
|
|
118
|
-
ThrowOnError extends boolean = false,
|
|
119
|
-
>(
|
|
120
|
-
options?: Options<KeysControllerGetProvenanceCryptoKeyData, ThrowOnError>,
|
|
121
|
-
) => {
|
|
122
|
-
return (options?.client ?? _heyApiClient).get<
|
|
123
|
-
KeysControllerGetProvenanceCryptoKeyResponses,
|
|
124
|
-
unknown,
|
|
125
|
-
ThrowOnError
|
|
126
|
-
>({
|
|
127
|
-
url: "/keys",
|
|
128
|
-
...options,
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export const quotesControllerCreateQuote = <
|
|
133
|
-
ThrowOnError extends boolean = false,
|
|
134
|
-
>(
|
|
135
|
-
options: Options<QuotesControllerCreateQuoteData, ThrowOnError>,
|
|
136
|
-
) => {
|
|
137
|
-
return (options.client ?? _heyApiClient).post<
|
|
138
|
-
QuotesControllerCreateQuoteResponses,
|
|
139
|
-
QuotesControllerCreateQuoteErrors,
|
|
140
|
-
ThrowOnError
|
|
141
|
-
>({
|
|
142
|
-
security: [
|
|
143
|
-
{
|
|
144
|
-
name: "x-api-token",
|
|
145
|
-
type: "apiKey",
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
url: "/quotes",
|
|
149
|
-
...options,
|
|
150
|
-
headers: {
|
|
151
|
-
"Content-Type": "application/json",
|
|
152
|
-
...options.headers,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export const quotesControllerGetQuote = <ThrowOnError extends boolean = false>(
|
|
158
|
-
options: Options<QuotesControllerGetQuoteData, ThrowOnError>,
|
|
159
|
-
) => {
|
|
160
|
-
return (options.client ?? _heyApiClient).get<
|
|
161
|
-
QuotesControllerGetQuoteResponses,
|
|
162
|
-
QuotesControllerGetQuoteErrors,
|
|
163
|
-
ThrowOnError
|
|
164
|
-
>({
|
|
165
|
-
security: [
|
|
166
|
-
{
|
|
167
|
-
name: "x-api-token",
|
|
168
|
-
type: "apiKey",
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
url: "/quotes/{id}",
|
|
172
|
-
...options,
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
113
|
export const apiTokenControllerCreateToken = <
|
|
177
114
|
ThrowOnError extends boolean = false,
|
|
178
115
|
>(
|
|
@@ -266,72 +203,23 @@ export const apiTokenControllerUpdateToken = <
|
|
|
266
203
|
});
|
|
267
204
|
};
|
|
268
205
|
|
|
269
|
-
|
|
270
|
-
* Create new missions
|
|
271
|
-
* Create missions for specified zones and mission types.
|
|
272
|
-
*/
|
|
273
|
-
export const missionsControllerCreateMissions = <
|
|
206
|
+
export const conditionsControllerGetSunAltitudeTimeLimits = <
|
|
274
207
|
ThrowOnError extends boolean = false,
|
|
275
208
|
>(
|
|
276
|
-
options: Options<
|
|
277
|
-
|
|
278
|
-
return (options.client ?? _heyApiClient).post<
|
|
279
|
-
MissionsControllerCreateMissionsResponses,
|
|
280
|
-
MissionsControllerCreateMissionsErrors,
|
|
209
|
+
options: Options<
|
|
210
|
+
ConditionsControllerGetSunAltitudeTimeLimitsData,
|
|
281
211
|
ThrowOnError
|
|
282
|
-
|
|
283
|
-
url: "/missions",
|
|
284
|
-
...options,
|
|
285
|
-
headers: {
|
|
286
|
-
"Content-Type": "application/json",
|
|
287
|
-
...options.headers,
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Update missions
|
|
294
|
-
* Update missions' rewards or cancel them altogether
|
|
295
|
-
*/
|
|
296
|
-
export const missionsControllerUpdateMissions = <
|
|
297
|
-
ThrowOnError extends boolean = false,
|
|
298
|
-
>(
|
|
299
|
-
options: Options<MissionsControllerUpdateMissionsData, ThrowOnError>,
|
|
212
|
+
>,
|
|
300
213
|
) => {
|
|
301
|
-
return (options.client ?? _heyApiClient).
|
|
302
|
-
|
|
214
|
+
return (options.client ?? _heyApiClient).get<
|
|
215
|
+
ConditionsControllerGetSunAltitudeTimeLimitsResponses,
|
|
303
216
|
unknown,
|
|
304
217
|
ThrowOnError
|
|
305
218
|
>({
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
"Content-Type": "application/json",
|
|
310
|
-
...options.headers,
|
|
311
|
-
},
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Claim rewards for a mission
|
|
317
|
-
* Claim rewards for a completed flight within a mission
|
|
318
|
-
*/
|
|
319
|
-
export const missionsControllerClaimRewards = <
|
|
320
|
-
ThrowOnError extends boolean = false,
|
|
321
|
-
>(
|
|
322
|
-
options: Options<MissionsControllerClaimRewardsData, ThrowOnError>,
|
|
323
|
-
) => {
|
|
324
|
-
return (options.client ?? _heyApiClient).post<
|
|
325
|
-
MissionsControllerClaimRewardsResponses,
|
|
326
|
-
MissionsControllerClaimRewardsErrors,
|
|
327
|
-
ThrowOnError
|
|
328
|
-
>({
|
|
329
|
-
url: "/missions/{id}/rewards",
|
|
219
|
+
responseTransformer:
|
|
220
|
+
conditionsControllerGetSunAltitudeTimeLimitsResponseTransformer,
|
|
221
|
+
url: "/conditions/sun-altitude",
|
|
330
222
|
...options,
|
|
331
|
-
headers: {
|
|
332
|
-
"Content-Type": "application/json",
|
|
333
|
-
...options.headers,
|
|
334
|
-
},
|
|
335
223
|
});
|
|
336
224
|
};
|
|
337
225
|
|
|
@@ -372,7 +260,6 @@ export const flightsControllerGetFlight = <
|
|
|
372
260
|
type: "apiKey",
|
|
373
261
|
},
|
|
374
262
|
],
|
|
375
|
-
responseTransformer: flightsControllerGetFlightResponseTransformer,
|
|
376
263
|
url: "/flights/{flightId}",
|
|
377
264
|
...options,
|
|
378
265
|
});
|
|
@@ -429,22 +316,107 @@ export const flightsControllerValidateFlight = <
|
|
|
429
316
|
});
|
|
430
317
|
};
|
|
431
318
|
|
|
432
|
-
export const
|
|
319
|
+
export const keysControllerGetProvenanceCryptoKey = <
|
|
433
320
|
ThrowOnError extends boolean = false,
|
|
434
321
|
>(
|
|
435
|
-
options
|
|
436
|
-
|
|
322
|
+
options?: Options<KeysControllerGetProvenanceCryptoKeyData, ThrowOnError>,
|
|
323
|
+
) => {
|
|
324
|
+
return (options?.client ?? _heyApiClient).get<
|
|
325
|
+
KeysControllerGetProvenanceCryptoKeyResponses,
|
|
326
|
+
unknown,
|
|
437
327
|
ThrowOnError
|
|
438
|
-
|
|
328
|
+
>({
|
|
329
|
+
url: "/keys",
|
|
330
|
+
...options,
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Create new missions
|
|
336
|
+
* Create missions for specified zones and mission types.
|
|
337
|
+
*/
|
|
338
|
+
export const missionsControllerCreateMissions = <
|
|
339
|
+
ThrowOnError extends boolean = false,
|
|
340
|
+
>(
|
|
341
|
+
options: Options<MissionsControllerCreateMissionsData, ThrowOnError>,
|
|
439
342
|
) => {
|
|
440
|
-
return (options.client ?? _heyApiClient).
|
|
441
|
-
|
|
343
|
+
return (options.client ?? _heyApiClient).post<
|
|
344
|
+
MissionsControllerCreateMissionsResponses,
|
|
345
|
+
MissionsControllerCreateMissionsErrors,
|
|
346
|
+
ThrowOnError
|
|
347
|
+
>({
|
|
348
|
+
url: "/missions",
|
|
349
|
+
...options,
|
|
350
|
+
headers: {
|
|
351
|
+
"Content-Type": "application/json",
|
|
352
|
+
...options.headers,
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Update missions
|
|
359
|
+
* Update missions' rewards or cancel them altogether
|
|
360
|
+
*/
|
|
361
|
+
export const missionsControllerUpdateMissions = <
|
|
362
|
+
ThrowOnError extends boolean = false,
|
|
363
|
+
>(
|
|
364
|
+
options: Options<MissionsControllerUpdateMissionsData, ThrowOnError>,
|
|
365
|
+
) => {
|
|
366
|
+
return (options.client ?? _heyApiClient).put<
|
|
367
|
+
MissionsControllerUpdateMissionsResponses,
|
|
442
368
|
unknown,
|
|
443
369
|
ThrowOnError
|
|
444
370
|
>({
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
371
|
+
url: "/missions",
|
|
372
|
+
...options,
|
|
373
|
+
headers: {
|
|
374
|
+
"Content-Type": "application/json",
|
|
375
|
+
...options.headers,
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
export const quotesControllerCreateQuote = <
|
|
381
|
+
ThrowOnError extends boolean = false,
|
|
382
|
+
>(
|
|
383
|
+
options: Options<QuotesControllerCreateQuoteData, ThrowOnError>,
|
|
384
|
+
) => {
|
|
385
|
+
return (options.client ?? _heyApiClient).post<
|
|
386
|
+
QuotesControllerCreateQuoteResponses,
|
|
387
|
+
QuotesControllerCreateQuoteErrors,
|
|
388
|
+
ThrowOnError
|
|
389
|
+
>({
|
|
390
|
+
security: [
|
|
391
|
+
{
|
|
392
|
+
name: "x-api-token",
|
|
393
|
+
type: "apiKey",
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
url: "/quotes",
|
|
397
|
+
...options,
|
|
398
|
+
headers: {
|
|
399
|
+
"Content-Type": "application/json",
|
|
400
|
+
...options.headers,
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
export const quotesControllerGetQuote = <ThrowOnError extends boolean = false>(
|
|
406
|
+
options: Options<QuotesControllerGetQuoteData, ThrowOnError>,
|
|
407
|
+
) => {
|
|
408
|
+
return (options.client ?? _heyApiClient).get<
|
|
409
|
+
QuotesControllerGetQuoteResponses,
|
|
410
|
+
QuotesControllerGetQuoteErrors,
|
|
411
|
+
ThrowOnError
|
|
412
|
+
>({
|
|
413
|
+
security: [
|
|
414
|
+
{
|
|
415
|
+
name: "x-api-token",
|
|
416
|
+
type: "apiKey",
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
url: "/quotes/{id}",
|
|
448
420
|
...options,
|
|
449
421
|
});
|
|
450
422
|
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import type {
|
|
3
3
|
ApiTokenControllerUpdateTokenResponse,
|
|
4
4
|
ConditionsControllerGetSunAltitudeTimeLimitsResponse,
|
|
5
|
-
FlightsControllerGetFlightResponse,
|
|
6
5
|
FlightsControllerValidateFlightResponse,
|
|
7
6
|
} from "./types.gen.js";
|
|
8
7
|
|
|
@@ -19,31 +18,6 @@ export const apiTokenControllerUpdateTokenResponseTransformer = async (
|
|
|
19
18
|
return data;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
const flightDtoSchemaResponseTransformer = (data: any) => {
|
|
23
|
-
data.token_id = BigInt(data.token_id.toString());
|
|
24
|
-
data.mission_id = BigInt(data.mission_id.toString());
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const flightsControllerGetFlightResponseTransformer = async (
|
|
29
|
-
data: any,
|
|
30
|
-
): Promise<FlightsControllerGetFlightResponse> => {
|
|
31
|
-
data = flightDtoSchemaResponseTransformer(data);
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const validateFlightResponseDtoSchemaResponseTransformer = (data: any) => {
|
|
36
|
-
data.flightId = BigInt(data.flightId.toString());
|
|
37
|
-
return data;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const flightsControllerValidateFlightResponseTransformer = async (
|
|
41
|
-
data: any,
|
|
42
|
-
): Promise<FlightsControllerValidateFlightResponse> => {
|
|
43
|
-
data = validateFlightResponseDtoSchemaResponseTransformer(data);
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
21
|
const getTimeLimitsForSunAltitudeResponseSchemaResponseTransformer = (
|
|
48
22
|
data: any,
|
|
49
23
|
) => {
|
|
@@ -65,3 +39,15 @@ export const conditionsControllerGetSunAltitudeTimeLimitsResponseTransformer =
|
|
|
65
39
|
data = getTimeLimitsForSunAltitudeResponseSchemaResponseTransformer(data);
|
|
66
40
|
return data;
|
|
67
41
|
};
|
|
42
|
+
|
|
43
|
+
const validateFlightResponseDtoSchemaResponseTransformer = (data: any) => {
|
|
44
|
+
data.flightId = BigInt(data.flightId.toString());
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const flightsControllerValidateFlightResponseTransformer = async (
|
|
49
|
+
data: any,
|
|
50
|
+
): Promise<FlightsControllerValidateFlightResponse> => {
|
|
51
|
+
data = validateFlightResponseDtoSchemaResponseTransformer(data);
|
|
52
|
+
return data;
|
|
53
|
+
};
|