@voyantjs/extras 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.
@@ -0,0 +1,564 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ type Env = {
3
+ Variables: {
4
+ db: PostgresJsDatabase;
5
+ userId?: string;
6
+ };
7
+ };
8
+ export declare const extrasRoutes: import("hono/hono-base").HonoBase<Env, {
9
+ "/product-extras": {
10
+ $get: {
11
+ input: {};
12
+ output: {
13
+ data: {
14
+ id: string;
15
+ productId: string;
16
+ code: string | null;
17
+ name: string;
18
+ description: string | null;
19
+ selectionType: "optional" | "required" | "default_selected" | "unavailable";
20
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
21
+ pricedPerPerson: boolean;
22
+ minQuantity: number | null;
23
+ maxQuantity: number | null;
24
+ defaultQuantity: number | null;
25
+ active: boolean;
26
+ sortOrder: number;
27
+ metadata: {
28
+ [x: string]: import("hono/utils/types").JSONValue;
29
+ } | null;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ }[];
33
+ total: number;
34
+ limit: number;
35
+ offset: number;
36
+ };
37
+ outputFormat: "json";
38
+ status: import("hono/utils/http-status").ContentfulStatusCode;
39
+ };
40
+ };
41
+ } & {
42
+ "/product-extras": {
43
+ $post: {
44
+ input: {};
45
+ output: {
46
+ data: {
47
+ id: string;
48
+ name: string;
49
+ productId: string;
50
+ code: string | null;
51
+ description: string | null;
52
+ selectionType: "optional" | "required" | "default_selected" | "unavailable";
53
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
54
+ pricedPerPerson: boolean;
55
+ minQuantity: number | null;
56
+ maxQuantity: number | null;
57
+ defaultQuantity: number | null;
58
+ active: boolean;
59
+ sortOrder: number;
60
+ metadata: {
61
+ [x: string]: import("hono/utils/types").JSONValue;
62
+ } | null;
63
+ createdAt: string;
64
+ updatedAt: string;
65
+ } | null;
66
+ };
67
+ outputFormat: "json";
68
+ status: 201;
69
+ };
70
+ };
71
+ } & {
72
+ "/product-extras/:id": {
73
+ $get: {
74
+ input: {
75
+ param: {
76
+ id: string;
77
+ };
78
+ };
79
+ output: {
80
+ error: string;
81
+ };
82
+ outputFormat: "json";
83
+ status: 404;
84
+ } | {
85
+ input: {
86
+ param: {
87
+ id: string;
88
+ };
89
+ };
90
+ output: {
91
+ data: {
92
+ id: string;
93
+ productId: string;
94
+ code: string | null;
95
+ name: string;
96
+ description: string | null;
97
+ selectionType: "optional" | "required" | "default_selected" | "unavailable";
98
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
99
+ pricedPerPerson: boolean;
100
+ minQuantity: number | null;
101
+ maxQuantity: number | null;
102
+ defaultQuantity: number | null;
103
+ active: boolean;
104
+ sortOrder: number;
105
+ metadata: {
106
+ [x: string]: import("hono/utils/types").JSONValue;
107
+ } | null;
108
+ createdAt: string;
109
+ updatedAt: string;
110
+ };
111
+ };
112
+ outputFormat: "json";
113
+ status: import("hono/utils/http-status").ContentfulStatusCode;
114
+ };
115
+ };
116
+ } & {
117
+ "/product-extras/:id": {
118
+ $patch: {
119
+ input: {
120
+ param: {
121
+ id: string;
122
+ };
123
+ };
124
+ output: {
125
+ error: string;
126
+ };
127
+ outputFormat: "json";
128
+ status: 404;
129
+ } | {
130
+ input: {
131
+ param: {
132
+ id: string;
133
+ };
134
+ };
135
+ output: {
136
+ data: {
137
+ id: string;
138
+ productId: string;
139
+ code: string | null;
140
+ name: string;
141
+ description: string | null;
142
+ selectionType: "optional" | "required" | "default_selected" | "unavailable";
143
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
144
+ pricedPerPerson: boolean;
145
+ minQuantity: number | null;
146
+ maxQuantity: number | null;
147
+ defaultQuantity: number | null;
148
+ active: boolean;
149
+ sortOrder: number;
150
+ metadata: {
151
+ [x: string]: import("hono/utils/types").JSONValue;
152
+ } | null;
153
+ createdAt: string;
154
+ updatedAt: string;
155
+ };
156
+ };
157
+ outputFormat: "json";
158
+ status: import("hono/utils/http-status").ContentfulStatusCode;
159
+ };
160
+ };
161
+ } & {
162
+ "/product-extras/:id": {
163
+ $delete: {
164
+ input: {
165
+ param: {
166
+ id: string;
167
+ };
168
+ };
169
+ output: {
170
+ error: string;
171
+ };
172
+ outputFormat: "json";
173
+ status: 404;
174
+ } | {
175
+ input: {
176
+ param: {
177
+ id: string;
178
+ };
179
+ };
180
+ output: {
181
+ success: true;
182
+ };
183
+ outputFormat: "json";
184
+ status: import("hono/utils/http-status").ContentfulStatusCode;
185
+ };
186
+ };
187
+ } & {
188
+ "/option-extra-configs": {
189
+ $get: {
190
+ input: {};
191
+ output: {
192
+ data: {
193
+ id: string;
194
+ optionId: string;
195
+ productExtraId: string;
196
+ selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
197
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free" | null;
198
+ pricedPerPerson: boolean | null;
199
+ minQuantity: number | null;
200
+ maxQuantity: number | null;
201
+ defaultQuantity: number | null;
202
+ isDefault: boolean;
203
+ active: boolean;
204
+ sortOrder: number;
205
+ notes: string | null;
206
+ metadata: {
207
+ [x: string]: import("hono/utils/types").JSONValue;
208
+ } | null;
209
+ createdAt: string;
210
+ updatedAt: string;
211
+ }[];
212
+ total: number;
213
+ limit: number;
214
+ offset: number;
215
+ };
216
+ outputFormat: "json";
217
+ status: import("hono/utils/http-status").ContentfulStatusCode;
218
+ };
219
+ };
220
+ } & {
221
+ "/option-extra-configs": {
222
+ $post: {
223
+ input: {};
224
+ output: {
225
+ data: {
226
+ id: string;
227
+ selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
228
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free" | null;
229
+ pricedPerPerson: boolean | null;
230
+ minQuantity: number | null;
231
+ maxQuantity: number | null;
232
+ defaultQuantity: number | null;
233
+ active: boolean;
234
+ sortOrder: number;
235
+ metadata: {
236
+ [x: string]: import("hono/utils/types").JSONValue;
237
+ } | null;
238
+ createdAt: string;
239
+ updatedAt: string;
240
+ optionId: string;
241
+ productExtraId: string;
242
+ isDefault: boolean;
243
+ notes: string | null;
244
+ } | null;
245
+ };
246
+ outputFormat: "json";
247
+ status: 201;
248
+ };
249
+ };
250
+ } & {
251
+ "/option-extra-configs/:id": {
252
+ $get: {
253
+ input: {
254
+ param: {
255
+ id: string;
256
+ };
257
+ };
258
+ output: {
259
+ error: string;
260
+ };
261
+ outputFormat: "json";
262
+ status: 404;
263
+ } | {
264
+ input: {
265
+ param: {
266
+ id: string;
267
+ };
268
+ };
269
+ output: {
270
+ data: {
271
+ id: string;
272
+ optionId: string;
273
+ productExtraId: string;
274
+ selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
275
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free" | null;
276
+ pricedPerPerson: boolean | null;
277
+ minQuantity: number | null;
278
+ maxQuantity: number | null;
279
+ defaultQuantity: number | null;
280
+ isDefault: boolean;
281
+ active: boolean;
282
+ sortOrder: number;
283
+ notes: string | null;
284
+ metadata: {
285
+ [x: string]: import("hono/utils/types").JSONValue;
286
+ } | null;
287
+ createdAt: string;
288
+ updatedAt: string;
289
+ };
290
+ };
291
+ outputFormat: "json";
292
+ status: import("hono/utils/http-status").ContentfulStatusCode;
293
+ };
294
+ };
295
+ } & {
296
+ "/option-extra-configs/:id": {
297
+ $patch: {
298
+ input: {
299
+ param: {
300
+ id: string;
301
+ };
302
+ };
303
+ output: {
304
+ error: string;
305
+ };
306
+ outputFormat: "json";
307
+ status: 404;
308
+ } | {
309
+ input: {
310
+ param: {
311
+ id: string;
312
+ };
313
+ };
314
+ output: {
315
+ data: {
316
+ id: string;
317
+ optionId: string;
318
+ productExtraId: string;
319
+ selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
320
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free" | null;
321
+ pricedPerPerson: boolean | null;
322
+ minQuantity: number | null;
323
+ maxQuantity: number | null;
324
+ defaultQuantity: number | null;
325
+ isDefault: boolean;
326
+ active: boolean;
327
+ sortOrder: number;
328
+ notes: string | null;
329
+ metadata: {
330
+ [x: string]: import("hono/utils/types").JSONValue;
331
+ } | null;
332
+ createdAt: string;
333
+ updatedAt: string;
334
+ };
335
+ };
336
+ outputFormat: "json";
337
+ status: import("hono/utils/http-status").ContentfulStatusCode;
338
+ };
339
+ };
340
+ } & {
341
+ "/option-extra-configs/:id": {
342
+ $delete: {
343
+ input: {
344
+ param: {
345
+ id: string;
346
+ };
347
+ };
348
+ output: {
349
+ error: string;
350
+ };
351
+ outputFormat: "json";
352
+ status: 404;
353
+ } | {
354
+ input: {
355
+ param: {
356
+ id: string;
357
+ };
358
+ };
359
+ output: {
360
+ success: true;
361
+ };
362
+ outputFormat: "json";
363
+ status: import("hono/utils/http-status").ContentfulStatusCode;
364
+ };
365
+ };
366
+ } & {
367
+ "/booking-extras": {
368
+ $get: {
369
+ input: {};
370
+ output: {
371
+ data: {
372
+ id: string;
373
+ bookingId: string;
374
+ productExtraId: string | null;
375
+ optionExtraConfigId: string | null;
376
+ name: string;
377
+ description: string | null;
378
+ status: "draft" | "selected" | "confirmed" | "cancelled" | "fulfilled";
379
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
380
+ pricedPerPerson: boolean;
381
+ quantity: number;
382
+ sellCurrency: string;
383
+ unitSellAmountCents: number | null;
384
+ totalSellAmountCents: number | null;
385
+ costCurrency: string | null;
386
+ unitCostAmountCents: number | null;
387
+ totalCostAmountCents: number | null;
388
+ notes: string | null;
389
+ metadata: {
390
+ [x: string]: import("hono/utils/types").JSONValue;
391
+ } | null;
392
+ createdAt: string;
393
+ updatedAt: string;
394
+ }[];
395
+ total: number;
396
+ limit: number;
397
+ offset: number;
398
+ };
399
+ outputFormat: "json";
400
+ status: import("hono/utils/http-status").ContentfulStatusCode;
401
+ };
402
+ };
403
+ } & {
404
+ "/booking-extras": {
405
+ $post: {
406
+ input: {};
407
+ output: {
408
+ data: {
409
+ id: string;
410
+ name: string;
411
+ description: string | null;
412
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
413
+ pricedPerPerson: boolean;
414
+ metadata: {
415
+ [x: string]: import("hono/utils/types").JSONValue;
416
+ } | null;
417
+ createdAt: string;
418
+ updatedAt: string;
419
+ productExtraId: string | null;
420
+ notes: string | null;
421
+ bookingId: string;
422
+ optionExtraConfigId: string | null;
423
+ status: "draft" | "selected" | "confirmed" | "cancelled" | "fulfilled";
424
+ quantity: number;
425
+ sellCurrency: string;
426
+ unitSellAmountCents: number | null;
427
+ totalSellAmountCents: number | null;
428
+ costCurrency: string | null;
429
+ unitCostAmountCents: number | null;
430
+ totalCostAmountCents: number | null;
431
+ } | null;
432
+ };
433
+ outputFormat: "json";
434
+ status: 201;
435
+ };
436
+ };
437
+ } & {
438
+ "/booking-extras/:id": {
439
+ $get: {
440
+ input: {
441
+ param: {
442
+ id: string;
443
+ };
444
+ };
445
+ output: {
446
+ error: string;
447
+ };
448
+ outputFormat: "json";
449
+ status: 404;
450
+ } | {
451
+ input: {
452
+ param: {
453
+ id: string;
454
+ };
455
+ };
456
+ output: {
457
+ data: {
458
+ id: string;
459
+ bookingId: string;
460
+ productExtraId: string | null;
461
+ optionExtraConfigId: string | null;
462
+ name: string;
463
+ description: string | null;
464
+ status: "draft" | "selected" | "confirmed" | "cancelled" | "fulfilled";
465
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
466
+ pricedPerPerson: boolean;
467
+ quantity: number;
468
+ sellCurrency: string;
469
+ unitSellAmountCents: number | null;
470
+ totalSellAmountCents: number | null;
471
+ costCurrency: string | null;
472
+ unitCostAmountCents: number | null;
473
+ totalCostAmountCents: number | null;
474
+ notes: string | null;
475
+ metadata: {
476
+ [x: string]: import("hono/utils/types").JSONValue;
477
+ } | null;
478
+ createdAt: string;
479
+ updatedAt: string;
480
+ };
481
+ };
482
+ outputFormat: "json";
483
+ status: import("hono/utils/http-status").ContentfulStatusCode;
484
+ };
485
+ };
486
+ } & {
487
+ "/booking-extras/:id": {
488
+ $patch: {
489
+ input: {
490
+ param: {
491
+ id: string;
492
+ };
493
+ };
494
+ output: {
495
+ error: string;
496
+ };
497
+ outputFormat: "json";
498
+ status: 404;
499
+ } | {
500
+ input: {
501
+ param: {
502
+ id: string;
503
+ };
504
+ };
505
+ output: {
506
+ data: {
507
+ id: string;
508
+ bookingId: string;
509
+ productExtraId: string | null;
510
+ optionExtraConfigId: string | null;
511
+ name: string;
512
+ description: string | null;
513
+ status: "draft" | "selected" | "confirmed" | "cancelled" | "fulfilled";
514
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
515
+ pricedPerPerson: boolean;
516
+ quantity: number;
517
+ sellCurrency: string;
518
+ unitSellAmountCents: number | null;
519
+ totalSellAmountCents: number | null;
520
+ costCurrency: string | null;
521
+ unitCostAmountCents: number | null;
522
+ totalCostAmountCents: number | null;
523
+ notes: string | null;
524
+ metadata: {
525
+ [x: string]: import("hono/utils/types").JSONValue;
526
+ } | null;
527
+ createdAt: string;
528
+ updatedAt: string;
529
+ };
530
+ };
531
+ outputFormat: "json";
532
+ status: import("hono/utils/http-status").ContentfulStatusCode;
533
+ };
534
+ };
535
+ } & {
536
+ "/booking-extras/:id": {
537
+ $delete: {
538
+ input: {
539
+ param: {
540
+ id: string;
541
+ };
542
+ };
543
+ output: {
544
+ error: string;
545
+ };
546
+ outputFormat: "json";
547
+ status: 404;
548
+ } | {
549
+ input: {
550
+ param: {
551
+ id: string;
552
+ };
553
+ };
554
+ output: {
555
+ success: true;
556
+ };
557
+ outputFormat: "json";
558
+ status: import("hono/utils/http-status").ContentfulStatusCode;
559
+ };
560
+ };
561
+ }, "/", "/booking-extras/:id">;
562
+ export type ExtrasRoutes = typeof extrasRoutes;
563
+ export {};
564
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAgBjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA4GrB,CAAA;AAEJ,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAA"}
package/dist/routes.js ADDED
@@ -0,0 +1,85 @@
1
+ import { Hono } from "hono";
2
+ import { extrasService } from "./service.js";
3
+ import { bookingExtraListQuerySchema, insertBookingExtraSchema, insertOptionExtraConfigSchema, insertProductExtraSchema, optionExtraConfigListQuerySchema, productExtraListQuerySchema, updateBookingExtraSchema, updateOptionExtraConfigSchema, updateProductExtraSchema, } from "./validation.js";
4
+ export const extrasRoutes = new Hono()
5
+ .get("/product-extras", async (c) => {
6
+ const query = productExtraListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
7
+ return c.json(await extrasService.listProductExtras(c.get("db"), query));
8
+ })
9
+ .post("/product-extras", async (c) => {
10
+ return c.json({
11
+ data: await extrasService.createProductExtra(c.get("db"), insertProductExtraSchema.parse(await c.req.json())),
12
+ }, 201);
13
+ })
14
+ .get("/product-extras/:id", async (c) => {
15
+ const row = await extrasService.getProductExtraById(c.get("db"), c.req.param("id"));
16
+ if (!row)
17
+ return c.json({ error: "Product extra not found" }, 404);
18
+ return c.json({ data: row });
19
+ })
20
+ .patch("/product-extras/:id", async (c) => {
21
+ const row = await extrasService.updateProductExtra(c.get("db"), c.req.param("id"), updateProductExtraSchema.parse(await c.req.json()));
22
+ if (!row)
23
+ return c.json({ error: "Product extra not found" }, 404);
24
+ return c.json({ data: row });
25
+ })
26
+ .delete("/product-extras/:id", async (c) => {
27
+ const row = await extrasService.deleteProductExtra(c.get("db"), c.req.param("id"));
28
+ if (!row)
29
+ return c.json({ error: "Product extra not found" }, 404);
30
+ return c.json({ success: true });
31
+ })
32
+ .get("/option-extra-configs", async (c) => {
33
+ const query = optionExtraConfigListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
34
+ return c.json(await extrasService.listOptionExtraConfigs(c.get("db"), query));
35
+ })
36
+ .post("/option-extra-configs", async (c) => {
37
+ return c.json({
38
+ data: await extrasService.createOptionExtraConfig(c.get("db"), insertOptionExtraConfigSchema.parse(await c.req.json())),
39
+ }, 201);
40
+ })
41
+ .get("/option-extra-configs/:id", async (c) => {
42
+ const row = await extrasService.getOptionExtraConfigById(c.get("db"), c.req.param("id"));
43
+ if (!row)
44
+ return c.json({ error: "Option extra config not found" }, 404);
45
+ return c.json({ data: row });
46
+ })
47
+ .patch("/option-extra-configs/:id", async (c) => {
48
+ const row = await extrasService.updateOptionExtraConfig(c.get("db"), c.req.param("id"), updateOptionExtraConfigSchema.parse(await c.req.json()));
49
+ if (!row)
50
+ return c.json({ error: "Option extra config not found" }, 404);
51
+ return c.json({ data: row });
52
+ })
53
+ .delete("/option-extra-configs/:id", async (c) => {
54
+ const row = await extrasService.deleteOptionExtraConfig(c.get("db"), c.req.param("id"));
55
+ if (!row)
56
+ return c.json({ error: "Option extra config not found" }, 404);
57
+ return c.json({ success: true });
58
+ })
59
+ .get("/booking-extras", async (c) => {
60
+ const query = bookingExtraListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
61
+ return c.json(await extrasService.listBookingExtras(c.get("db"), query));
62
+ })
63
+ .post("/booking-extras", async (c) => {
64
+ return c.json({
65
+ data: await extrasService.createBookingExtra(c.get("db"), insertBookingExtraSchema.parse(await c.req.json())),
66
+ }, 201);
67
+ })
68
+ .get("/booking-extras/:id", async (c) => {
69
+ const row = await extrasService.getBookingExtraById(c.get("db"), c.req.param("id"));
70
+ if (!row)
71
+ return c.json({ error: "Booking extra not found" }, 404);
72
+ return c.json({ data: row });
73
+ })
74
+ .patch("/booking-extras/:id", async (c) => {
75
+ const row = await extrasService.updateBookingExtra(c.get("db"), c.req.param("id"), updateBookingExtraSchema.parse(await c.req.json()));
76
+ if (!row)
77
+ return c.json({ error: "Booking extra not found" }, 404);
78
+ return c.json({ data: row });
79
+ })
80
+ .delete("/booking-extras/:id", async (c) => {
81
+ const row = await extrasService.deleteBookingExtra(c.get("db"), c.req.param("id"));
82
+ if (!row)
83
+ return c.json({ error: "Booking extra not found" }, 404);
84
+ return c.json({ success: true });
85
+ });