@layer-drone/protocol 0.0.3 → 0.0.6
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 +561 -0
- package/dist/index.d.ts +561 -0
- package/dist/index.js +390 -0
- package/dist/index.mjs +343 -0
- package/package.json +6 -1
- package/src/client/sdk.gen.ts +64 -29
- package/src/client/types.gen.ts +59 -6
- package/.eslintrc.js +0 -19
- package/.prettierrc.js +0 -4
- package/.turbo/turbo-build.log +0 -18
- package/.turbo/turbo-lint.log +0 -4
- package/CHANGELOG.md +0 -8
- package/openapi-ts.config.ts +0 -7
- package/scripts/generate-event-type.ts +0 -35
- package/tsconfig.json +0 -12
package/dist/index.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
Event: () => Event,
|
|
25
|
+
apiTokenControllerCreateToken: () => apiTokenControllerCreateToken,
|
|
26
|
+
apiTokenControllerDeleteToken: () => apiTokenControllerDeleteToken,
|
|
27
|
+
apiTokenControllerGetToken: () => apiTokenControllerGetToken,
|
|
28
|
+
apiTokenControllerUpdateToken: () => apiTokenControllerUpdateToken,
|
|
29
|
+
appControllerGetHello: () => appControllerGetHello,
|
|
30
|
+
flightsControllerCreatePresignedUrls: () => flightsControllerCreatePresignedUrls,
|
|
31
|
+
flightsControllerGenerateFlightId: () => flightsControllerGenerateFlightId,
|
|
32
|
+
flightsControllerValidateFlight: () => flightsControllerValidateFlight,
|
|
33
|
+
keysControllerGetProvenanceCryptoKey: () => keysControllerGetProvenanceCryptoKey,
|
|
34
|
+
parseWebhookEvent: () => parseWebhookEvent,
|
|
35
|
+
quotesControllerCreateQuote: () => quotesControllerCreateQuote,
|
|
36
|
+
rewardsControllerDepositRewards: () => rewardsControllerDepositRewards,
|
|
37
|
+
rewardsControllerDistributeRewards: () => rewardsControllerDistributeRewards,
|
|
38
|
+
schemaControllerGetEventSchema: () => schemaControllerGetEventSchema,
|
|
39
|
+
webhooksControllerCreate: () => webhooksControllerCreate,
|
|
40
|
+
webhooksControllerDelete: () => webhooksControllerDelete,
|
|
41
|
+
webhooksControllerGet: () => webhooksControllerGet,
|
|
42
|
+
webhooksControllerGetMany: () => webhooksControllerGetMany,
|
|
43
|
+
webhooksControllerGetStatus: () => webhooksControllerGetStatus,
|
|
44
|
+
webhooksControllerRegenerateSecret: () => webhooksControllerRegenerateSecret,
|
|
45
|
+
webhooksControllerTest: () => webhooksControllerTest,
|
|
46
|
+
webhooksControllerUpdate: () => webhooksControllerUpdate
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(index_exports);
|
|
49
|
+
|
|
50
|
+
// src/client/client.gen.ts
|
|
51
|
+
var import_client_fetch = require("@hey-api/client-fetch");
|
|
52
|
+
var client = (0, import_client_fetch.createClient)((0, import_client_fetch.createConfig)());
|
|
53
|
+
|
|
54
|
+
// src/client/sdk.gen.ts
|
|
55
|
+
var appControllerGetHello = /* @__PURE__ */ __name((options) => {
|
|
56
|
+
return (options?.client ?? client).get({
|
|
57
|
+
url: "/",
|
|
58
|
+
...options
|
|
59
|
+
});
|
|
60
|
+
}, "appControllerGetHello");
|
|
61
|
+
var keysControllerGetProvenanceCryptoKey = /* @__PURE__ */ __name((options) => {
|
|
62
|
+
return (options?.client ?? client).get({
|
|
63
|
+
url: "/keys",
|
|
64
|
+
...options
|
|
65
|
+
});
|
|
66
|
+
}, "keysControllerGetProvenanceCryptoKey");
|
|
67
|
+
var rewardsControllerDepositRewards = /* @__PURE__ */ __name((options) => {
|
|
68
|
+
return (options.client ?? client).post({
|
|
69
|
+
security: [
|
|
70
|
+
{
|
|
71
|
+
name: "x-api-token",
|
|
72
|
+
type: "apiKey"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
url: "/rewards/deposit",
|
|
76
|
+
...options,
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
...options?.headers
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}, "rewardsControllerDepositRewards");
|
|
83
|
+
var rewardsControllerDistributeRewards = /* @__PURE__ */ __name((options) => {
|
|
84
|
+
return (options.client ?? client).post({
|
|
85
|
+
security: [
|
|
86
|
+
{
|
|
87
|
+
name: "x-api-token",
|
|
88
|
+
type: "apiKey"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
url: "/rewards/distribute",
|
|
92
|
+
...options,
|
|
93
|
+
headers: {
|
|
94
|
+
"Content-Type": "application/json",
|
|
95
|
+
...options?.headers
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}, "rewardsControllerDistributeRewards");
|
|
99
|
+
var apiTokenControllerCreateToken = /* @__PURE__ */ __name((options) => {
|
|
100
|
+
return (options.client ?? client).post({
|
|
101
|
+
security: [
|
|
102
|
+
{
|
|
103
|
+
name: "x-api-token",
|
|
104
|
+
type: "apiKey"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
url: "/tokens",
|
|
108
|
+
...options,
|
|
109
|
+
headers: {
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
...options?.headers
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}, "apiTokenControllerCreateToken");
|
|
115
|
+
var apiTokenControllerDeleteToken = /* @__PURE__ */ __name((options) => {
|
|
116
|
+
return (options.client ?? client).delete({
|
|
117
|
+
security: [
|
|
118
|
+
{
|
|
119
|
+
name: "x-api-token",
|
|
120
|
+
type: "apiKey"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
url: "/tokens/{id}",
|
|
124
|
+
...options
|
|
125
|
+
});
|
|
126
|
+
}, "apiTokenControllerDeleteToken");
|
|
127
|
+
var apiTokenControllerGetToken = /* @__PURE__ */ __name((options) => {
|
|
128
|
+
return (options.client ?? client).get({
|
|
129
|
+
security: [
|
|
130
|
+
{
|
|
131
|
+
name: "x-api-token",
|
|
132
|
+
type: "apiKey"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
url: "/tokens/{id}",
|
|
136
|
+
...options
|
|
137
|
+
});
|
|
138
|
+
}, "apiTokenControllerGetToken");
|
|
139
|
+
var apiTokenControllerUpdateToken = /* @__PURE__ */ __name((options) => {
|
|
140
|
+
return (options.client ?? client).patch({
|
|
141
|
+
security: [
|
|
142
|
+
{
|
|
143
|
+
name: "x-api-token",
|
|
144
|
+
type: "apiKey"
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
url: "/tokens/{id}",
|
|
148
|
+
...options,
|
|
149
|
+
headers: {
|
|
150
|
+
"Content-Type": "application/json",
|
|
151
|
+
...options?.headers
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}, "apiTokenControllerUpdateToken");
|
|
155
|
+
var quotesControllerCreateQuote = /* @__PURE__ */ __name((options) => {
|
|
156
|
+
return (options.client ?? client).post({
|
|
157
|
+
security: [
|
|
158
|
+
{
|
|
159
|
+
name: "x-api-token",
|
|
160
|
+
type: "apiKey"
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
url: "/quotes",
|
|
164
|
+
...options,
|
|
165
|
+
headers: {
|
|
166
|
+
"Content-Type": "application/json",
|
|
167
|
+
...options?.headers
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}, "quotesControllerCreateQuote");
|
|
171
|
+
var flightsControllerGenerateFlightId = /* @__PURE__ */ __name((options) => {
|
|
172
|
+
return (options.client ?? client).get({
|
|
173
|
+
security: [
|
|
174
|
+
{
|
|
175
|
+
name: "x-api-token",
|
|
176
|
+
type: "apiKey"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
url: "/flights/id",
|
|
180
|
+
...options
|
|
181
|
+
});
|
|
182
|
+
}, "flightsControllerGenerateFlightId");
|
|
183
|
+
var flightsControllerCreatePresignedUrls = /* @__PURE__ */ __name((options) => {
|
|
184
|
+
return (options.client ?? client).post({
|
|
185
|
+
security: [
|
|
186
|
+
{
|
|
187
|
+
name: "x-api-token",
|
|
188
|
+
type: "apiKey"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
url: "/flights/{flightId}/files",
|
|
192
|
+
...options,
|
|
193
|
+
headers: {
|
|
194
|
+
"Content-Type": "application/json",
|
|
195
|
+
...options?.headers
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}, "flightsControllerCreatePresignedUrls");
|
|
199
|
+
var flightsControllerValidateFlight = /* @__PURE__ */ __name((options) => {
|
|
200
|
+
return (options.client ?? client).post({
|
|
201
|
+
security: [
|
|
202
|
+
{
|
|
203
|
+
name: "x-api-token",
|
|
204
|
+
type: "apiKey"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
url: "/flights",
|
|
208
|
+
...options,
|
|
209
|
+
headers: {
|
|
210
|
+
"Content-Type": "application/json",
|
|
211
|
+
...options?.headers
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}, "flightsControllerValidateFlight");
|
|
215
|
+
var schemaControllerGetEventSchema = /* @__PURE__ */ __name((options) => {
|
|
216
|
+
return (options?.client ?? client).get({
|
|
217
|
+
url: "/schema/event",
|
|
218
|
+
...options
|
|
219
|
+
});
|
|
220
|
+
}, "schemaControllerGetEventSchema");
|
|
221
|
+
var webhooksControllerGetMany = /* @__PURE__ */ __name((options) => {
|
|
222
|
+
return (options.client ?? client).get({
|
|
223
|
+
security: [
|
|
224
|
+
{
|
|
225
|
+
name: "x-api-token",
|
|
226
|
+
type: "apiKey"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
url: "/org/{org_id}/webhooks",
|
|
230
|
+
...options
|
|
231
|
+
});
|
|
232
|
+
}, "webhooksControllerGetMany");
|
|
233
|
+
var webhooksControllerCreate = /* @__PURE__ */ __name((options) => {
|
|
234
|
+
return (options.client ?? client).post({
|
|
235
|
+
security: [
|
|
236
|
+
{
|
|
237
|
+
name: "x-api-token",
|
|
238
|
+
type: "apiKey"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
url: "/org/{org_id}/webhooks",
|
|
242
|
+
...options,
|
|
243
|
+
headers: {
|
|
244
|
+
"Content-Type": "application/json",
|
|
245
|
+
...options?.headers
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}, "webhooksControllerCreate");
|
|
249
|
+
var webhooksControllerDelete = /* @__PURE__ */ __name((options) => {
|
|
250
|
+
return (options.client ?? client).delete({
|
|
251
|
+
security: [
|
|
252
|
+
{
|
|
253
|
+
name: "x-api-token",
|
|
254
|
+
type: "apiKey"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
url: "/org/{org_id}/webhooks/{id}",
|
|
258
|
+
...options
|
|
259
|
+
});
|
|
260
|
+
}, "webhooksControllerDelete");
|
|
261
|
+
var webhooksControllerGet = /* @__PURE__ */ __name((options) => {
|
|
262
|
+
return (options.client ?? client).get({
|
|
263
|
+
security: [
|
|
264
|
+
{
|
|
265
|
+
name: "x-api-token",
|
|
266
|
+
type: "apiKey"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
url: "/org/{org_id}/webhooks/{id}",
|
|
270
|
+
...options
|
|
271
|
+
});
|
|
272
|
+
}, "webhooksControllerGet");
|
|
273
|
+
var webhooksControllerUpdate = /* @__PURE__ */ __name((options) => {
|
|
274
|
+
return (options.client ?? client).put({
|
|
275
|
+
security: [
|
|
276
|
+
{
|
|
277
|
+
name: "x-api-token",
|
|
278
|
+
type: "apiKey"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
url: "/org/{org_id}/webhooks/{id}",
|
|
282
|
+
...options,
|
|
283
|
+
headers: {
|
|
284
|
+
"Content-Type": "application/json",
|
|
285
|
+
...options?.headers
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}, "webhooksControllerUpdate");
|
|
289
|
+
var webhooksControllerRegenerateSecret = /* @__PURE__ */ __name((options) => {
|
|
290
|
+
return (options.client ?? client).post({
|
|
291
|
+
security: [
|
|
292
|
+
{
|
|
293
|
+
name: "x-api-token",
|
|
294
|
+
type: "apiKey"
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
url: "/org/{org_id}/webhooks/{id}/regenerate-secret",
|
|
298
|
+
...options
|
|
299
|
+
});
|
|
300
|
+
}, "webhooksControllerRegenerateSecret");
|
|
301
|
+
var webhooksControllerTest = /* @__PURE__ */ __name((options) => {
|
|
302
|
+
return (options.client ?? client).post({
|
|
303
|
+
security: [
|
|
304
|
+
{
|
|
305
|
+
name: "x-api-token",
|
|
306
|
+
type: "apiKey"
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
url: "/org/{org_id}/webhooks/{id}/test",
|
|
310
|
+
...options
|
|
311
|
+
});
|
|
312
|
+
}, "webhooksControllerTest");
|
|
313
|
+
var webhooksControllerGetStatus = /* @__PURE__ */ __name((options) => {
|
|
314
|
+
return (options.client ?? client).get({
|
|
315
|
+
security: [
|
|
316
|
+
{
|
|
317
|
+
name: "x-api-token",
|
|
318
|
+
type: "apiKey"
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
url: "/org/{org_id}/webhooks/{id}/status",
|
|
322
|
+
...options
|
|
323
|
+
});
|
|
324
|
+
}, "webhooksControllerGetStatus");
|
|
325
|
+
|
|
326
|
+
// src/event/types.gen.ts
|
|
327
|
+
var import_zod = require("zod");
|
|
328
|
+
var Event = import_zod.z.union([
|
|
329
|
+
import_zod.z.object({
|
|
330
|
+
id: import_zod.z.string(),
|
|
331
|
+
event_type: import_zod.z.literal("test"),
|
|
332
|
+
timestamp: import_zod.z.string(),
|
|
333
|
+
data: import_zod.z.object({
|
|
334
|
+
message: import_zod.z.string()
|
|
335
|
+
}).strict()
|
|
336
|
+
}).strict(),
|
|
337
|
+
import_zod.z.object({
|
|
338
|
+
id: import_zod.z.any(),
|
|
339
|
+
event_type: import_zod.z.literal("protocol.flight.submitted"),
|
|
340
|
+
timestamp: import_zod.z.any(),
|
|
341
|
+
data: import_zod.z.object({
|
|
342
|
+
flightId: import_zod.z.number(),
|
|
343
|
+
pilotAddress: import_zod.z.string(),
|
|
344
|
+
flightManifestUri: import_zod.z.string()
|
|
345
|
+
}).strict()
|
|
346
|
+
}).strict()
|
|
347
|
+
]);
|
|
348
|
+
|
|
349
|
+
// src/event/parser.ts
|
|
350
|
+
var WEBHOOK_SECRET_HEADER = "X-Webhook-Secret";
|
|
351
|
+
function parseWebhookEvent(req, webhookSecret) {
|
|
352
|
+
const secret = req.headers[WEBHOOK_SECRET_HEADER] || req.headers[WEBHOOK_SECRET_HEADER.toLowerCase()];
|
|
353
|
+
if (typeof secret !== "string") {
|
|
354
|
+
throw new Error("Webhook request signature is not a string");
|
|
355
|
+
}
|
|
356
|
+
if (!Buffer.isBuffer(req.body)) {
|
|
357
|
+
throw new Error("Webhook request body is not a Buffer");
|
|
358
|
+
}
|
|
359
|
+
if (secret !== webhookSecret) {
|
|
360
|
+
throw new Error("Invalid webhook secret");
|
|
361
|
+
}
|
|
362
|
+
return Event.parse(JSON.parse(req.body.toString("utf-8")));
|
|
363
|
+
}
|
|
364
|
+
__name(parseWebhookEvent, "parseWebhookEvent");
|
|
365
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
366
|
+
0 && (module.exports = {
|
|
367
|
+
Event,
|
|
368
|
+
apiTokenControllerCreateToken,
|
|
369
|
+
apiTokenControllerDeleteToken,
|
|
370
|
+
apiTokenControllerGetToken,
|
|
371
|
+
apiTokenControllerUpdateToken,
|
|
372
|
+
appControllerGetHello,
|
|
373
|
+
flightsControllerCreatePresignedUrls,
|
|
374
|
+
flightsControllerGenerateFlightId,
|
|
375
|
+
flightsControllerValidateFlight,
|
|
376
|
+
keysControllerGetProvenanceCryptoKey,
|
|
377
|
+
parseWebhookEvent,
|
|
378
|
+
quotesControllerCreateQuote,
|
|
379
|
+
rewardsControllerDepositRewards,
|
|
380
|
+
rewardsControllerDistributeRewards,
|
|
381
|
+
schemaControllerGetEventSchema,
|
|
382
|
+
webhooksControllerCreate,
|
|
383
|
+
webhooksControllerDelete,
|
|
384
|
+
webhooksControllerGet,
|
|
385
|
+
webhooksControllerGetMany,
|
|
386
|
+
webhooksControllerGetStatus,
|
|
387
|
+
webhooksControllerRegenerateSecret,
|
|
388
|
+
webhooksControllerTest,
|
|
389
|
+
webhooksControllerUpdate
|
|
390
|
+
});
|